may
may copied to clipboard
Structured concurrency support
Does it support structured concurrency in some way?
https://en.wikipedia.org/wiki/Structured_concurrency
There are several ways to control and wait the sub coroutines
- each created coroutine has a handle, you can join it to get the result, or just wait it to finish
- you can cancel or kill a coroutine by
unsafe { j.coroutine().cancel() };
-
May also support scoped version spawn. which would block until all the scoped coroutine finished. ref example
-
the join! macro would block until all the block finish, it's basically a scoped spawn for convenience. ref example
-
the select! macro block until any coroutine finish. ref example
-
there is also advanced sub coroutine control mechanism called cqueue which is the underlying implementation of the previous macros.