Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured concurrency support #78

Open
carlopires opened this issue Feb 4, 2020 · 1 comment
Open

Structured concurrency support #78

carlopires opened this issue Feb 4, 2020 · 1 comment

Comments

@carlopires
Copy link

Does it support structured concurrency in some way?

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

@Xudong-Huang
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants