-
Notifications
You must be signed in to change notification settings - Fork 147
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 AsyncBarrier.SignalAndWait(CancellationToken)
overload
#1330
Conversation
Also optimize the pre-existing code. The new overload returns `ValueTask` to leave open the option of optimizing to zero-allocation use via `IValueTaskSource`.
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.
The PR looks good to me. It is interesting that we defined the signature of the new method to return ValueTask, instead of Task, which seems to make two overloads to have different return types, while it doesn't really save any memory allocation in this case, because we either return Task.CompletedTask or a TaskCompletionSource is always created in the implementation. Do we really have a strong reason to adopt ValueTask to make the two overloads different here?
Yielding |
Also optimize the pre-existing code.
The new overload returns
ValueTask
to leave open the option of optimizing to zero-allocation use viaIValueTaskSource
.Closes #1329