Skip to content

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