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

Add async_generator<T> type #9

Closed
lewissbaker opened this issue May 7, 2017 · 1 comment
Closed

Add async_generator<T> type #9

lewissbaker opened this issue May 7, 2017 · 1 comment
Assignees

Comments

@lewissbaker
Copy link
Owner

Add a coroutine type that allows both co_yield and co_await.

@lewissbaker lewissbaker self-assigned this May 7, 2017
@lewissbaker
Copy link
Owner Author

Initial version of the async_generator has been added in f7bfad1

It uses an atomic integer to manage the state of the generator to handle potential races between consumer and producer coroutines and so has a cost of at least one atomic compare-exchange operation per item of the sequence.

In theory, if the compilers could guarantee tail-calls to await_suspend() and coroutine_handle::resume() then we could eliminate the need for this atomic integer. However, for the time-being the atomic integer is is needed to avoid blowing the stack by a potentially unbounded mutual recursion of producer/consumer coroutines.

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

1 participant