-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Remove CancelableEnumerator #10099
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
Remove CancelableEnumerator #10099
Conversation
@@ -406,10 +406,11 @@ async Task ExecuteInvocation() | |||
|
|||
try | |||
{ | |||
await foreach (var streamItem in enumerable) | |||
var enumerator = enumerable.GetAsyncEnumerator(streamCts.Token); |
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.
Should the enumerator
be disposed?
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.
Leave the await foreach and call .WithCancellation instead:
await foreach (var streamItem in enumerable.WithCancellation(streamCts.Token))
{
}
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.
Yes it should
We should make |
@@ -51,37 +51,10 @@ public IAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellati | |||
{ |
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.
registration
not referenced. Actually is the private class still needed?
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 class is still needed because we need to be able to cancel the inner stream operation from the token passed into GetASyncEnumerator
but you bring up a good point about the registration. It should be disposed
This comment was made automatically. If there is a problem contact [email protected]. I've triaged the above build. I've created/commented on the following issue(s) |
So in another PR we should work to remove more from the |
@@ -98,10 +71,6 @@ public CancelableAsyncEnumerable(IAsyncEnumerable<T> asyncEnumerable, Cancellati | |||
|
|||
public IAsyncEnumerator<object> GetAsyncEnumerator(CancellationToken cancellationToken = default) | |||
{ | |||
// Assume that this will be iterated through with await foreach which always passes a default token. | |||
// Instead use the token from the ctor. | |||
Debug.Assert(cancellationToken == default); |
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.
@mikaelm12 Why remove this Debug.Assert if we're still not using the cancellationToken being passed in? Don't we now need to link the token sources or assert the cancellationToken is not cancellable? Otherwise we're just ignoring it...
This reverts commit d37b2ca.
Fixes: #7960
Context: #6791 (comment)