Add low-level coroutine suspension notifications#372
Merged
Add low-level coroutine suspension notifications#372
Conversation
Member
|
Don't we need to add an |
Collaborator
Author
|
@oldnewthing right, I'll add that. |
oldnewthing
reviewed
Oct 10, 2019
strings/base_coroutine_foundation.h
Outdated
| } | ||
|
|
||
| template <typename T> | ||
| struct notify_awaiter |
Member
There was a problem hiding this comment.
Consider moving this out of impl so it can be used by user-defined promise types. (Like my simple_task<T>.)
Collaborator
Author
There was a problem hiding this comment.
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.
Scottj1s
approved these changes
Oct 15, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.