-
Notifications
You must be signed in to change notification settings - Fork 468
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 generator<T> coroutine type #5
Comments
Some questions for me as to the design:
There may be a performance advantage in storing a copy of the value in the generator's promise rather than a pointer to the value passed to co_yield, at least for fundamental types and possibly some other simple user-defined types. The elimination of an extra indirection when the consumer dereferences the iterator could be significant in some tight loops. Need to evaluate the performance impact of this approach on Clang which has more advanced coroutine optimisation than MSVC at the moment. |
Also need to consider custom allocators for the coroutine frame. I'm not a huge fan of making the allocator template parameter of the generator type (ie. This would also allow callers to pass stateful allocators rather than being limited to stateless allocators. eg. Something like template<typename ALLOCATOR>
cppcoro::generator<foo> some_func(std::allocator_arg_t, ALLOCATOR& alloc, P1 arg1, P2 arg2); |
Commit 40c6216 adds initial Still need to update README with some documentation. |
README has now been updated. |
test discovery
Add a new type
cppcoro::generator<T>
that allows you to write a coroutine that yields a sequence of values procedurally from within the coroutine using theco_yield
keyword.eg.
The text was updated successfully, but these errors were encountered: