Skip to content
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

use copy of initial state machine to get resumption back to zero #49

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

dsyme
Copy link
Contributor

@dsyme dsyme commented Oct 28, 2022

No description provided.

@abelbraaksma
Copy link
Member

Thanks for these improvements, @dsyme, and thanks for pairing with me to fix this gnarly issue! For posterity, the fix presented here does two things:

  • it creates a shadow copy of the original state machine just after creating of the state machine. It then uses this shadowed machine as the default state for the cloned enumerator (needed as soon as there is more than one call to GetAsyncEnumerator()). This replaces the Unchecked.defaultof hack I used in Fix resumability of iteration over IAsyncEnumerable<'T> #42, which only partially solved the issue, and created an nondeterministic state.
  • it removes some allocations and unnecessary logic in the GetAsyncEnumerator(), among other things, this removes the necessity for MemberwiseClone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix investigation Requires further or deeper investigation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants