-
Notifications
You must be signed in to change notification settings - Fork 262
Add low-level coroutine suspension notifications #372
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
Conversation
|
Don't we need to add an |
|
@oldnewthing right, I'll add that. |
strings/base_coroutine_foundation.h
Outdated
| } | ||
|
|
||
| template <typename T> | ||
| struct notify_awaiter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this out of impl so it can be used by user-defined promise types. (Like my simple_task<T>.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty invasive hook so I'll give it some time to bake, make sure it's what we really want, and then make a helper available outside the impl namespace.
The OS uses a form of activity tracking to log events that might complete asynchronously. When this is mixed with coroutines, the activity is tripped up because it does not realize that a suspension point may have switched the thread on which it is executing. This update provides a very low-level hook for use by WIL to notify the system that a coroutine is being suspended or resumed. As with the winrt_to_hresult_handler hook, this is intended for low-level interop with WIL and I don't recommend developers using this as a general purpose notification mechanism.
The "get_awaiter" implementation here is pretty convoluted, but fortunately C++23 will have more library support for coroutines including a "get_awaiter" like function that will be part of the standard library.