-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix resumability of iteration over IAsyncEnumerable<'T>
#42
Conversation
38113c2
to
1764157
Compare
…ctorings from #42 for smaller diffing
…ctorings from #42 for smaller diffing
…ctorings from #42 for smaller diffing
cfbe823
to
57e180c
Compare
Ok. So, here's what we're at now:
To emphasize the last point, I duplicated all tests we had so far, and made a synchronous and asynchronous batch. It is clear that the state of the |
9b8a459
to
cd8af87
Compare
…is, partially fixed Issue has to do with the MemberwiseClone() for shadowing the enumerator is not enough to reset the necessary states. Furthermore, after this is sorta fixed, the ValueTask that is used to keep the MoveNext boolean gets accessed twice asynchronously, which is not allowed. It also seems that using 'use' on the taskSeq.GetAsyncEnumerator fails by double disposing. This can probably be considered "by design" but should carefully be considered.
…validState exceptions
…ined, instead return default value for type
…ence is completed
… of the async stream
…h solves calling MoveNextAsync() multiple times after completion and removes the InvalidStateException
…cessed in lock step, or individually to completion
…w Enumerator, after a full loop through all items
…tors when tasks are yielded, instead of concrete
cd1b86f
to
c095488
Compare
…lex, mutable state scenario
56f226e
to
218f83b
Compare
Thanks and credits to @dsyme for helping me out today, and explaining more of, the resumable state machine logic. See #49 of that initial work to get resumption back to zero. This removes the hack that I used here, through There's still some cleaning up to do and apply suggested optimizations to the |
This is a continuation of #36. That PR merely added a bunch of tests and some small attempts at fixing this. These tests are deliberately failing as they showcase the issue at hand.
TODO:
GetAsyncEnumerator()
of thetaskSeq
CE and using it as an iteratortaskSeq
result must be equal, or, for side effects, show the side effects againMoveNextAsync
of thetaskSeq
CE after it returnsfalse
: it should continue to returnfalse
Current
before the first call toMoveNextAsync
(the docs say its behavior is undefined, but similar to howIEnumerator<_>
is implemented usually, just returnUnchecked.defaultof
).Current
after completion of a finite sequence (i.e. whenMoveNextAsync
has returnedfalse
).yielded
) tasks. If result is not immediate,MoveNextAsync()
called on a copied enumerator will returnFaulted
with an NREThe above scenarios presently return an
InvalidOperationException
, as described in detail in issue #39.