WICG/scheduling-apis

Structured concurrency and cancellation

Opened this issue · 0 comments

beorn commented

Hi,

Structured concurrency (task trees that share a cancellation & error propagation scope) is a very useful way to tame concurrent programming, and has been adopted in Kotlin, Swift, and other languages and frameworks.

Since this proposal deals with tasks and cancellability, are there any plans to enable structured concurrency? I think AsyncContext would enable propagation of signals and priorities through the "async call stack".

I presume cancellation would still be have to be cooperative, listening to a AbortController.signal, so it would make sense to make this signal available from within the task (possibly using AsyncContext).

Standard APIs (like fetch, setTimeout, etc) could of course be updated to listen to a default inherited "async AbortSignal" instead of manually passing them the signal, which would provide for an amazing DX.

Kind regards,
Bjorn