may icon indicating copy to clipboard operation
may copied to clipboard

Structured concurrency support

Open carlopires opened this issue 5 years ago • 1 comments

Does it support structured concurrency in some way?

https://en.wikipedia.org/wiki/Structured_concurrency

carlopires avatar Feb 04 '20 20:02 carlopires

There are several ways to control and wait the sub coroutines

  1. each created coroutine has a handle, you can join it to get the result, or just wait it to finish
  2. you can cancel or kill a coroutine by
unsafe { j.coroutine().cancel() };
  1. May also support scoped version spawn. which would block until all the scoped coroutine finished. ref example

  2. the join! macro would block until all the block finish, it's basically a scoped spawn for convenience. ref example

  3. the select! macro block until any coroutine finish. ref example

  4. there is also advanced sub coroutine control mechanism called cqueue which is the underlying implementation of the previous macros.

Xudong-Huang avatar Feb 05 '20 03:02 Xudong-Huang