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

Improve GetAsyncEnumerator, move inheritance of IAsyncDisposable #51

Merged
merged 4 commits into from
Oct 29, 2022

Conversation

abelbraaksma
Copy link
Member

@abelbraaksma abelbraaksma commented Oct 29, 2022

After the struggle with #42, some cleanup is needed, and some refactoring. Also, a few functional changes:

  • IAsyncEnumerable itself should not implement IAsyncDisposable, instead, only IAsyncEnumerator should implement that, by default, because it already inherits from that interface. This change prevents accidental use x = myTaskSeq code, which we really should prevent.
    Note: it is unlikely this would happen in practice, as we strictly return IAsyncEnumerable<'T>, however, someone creative could cast and succeed. Plus, it just doesn't make sense in the current implementation.
  • Improve GetAsyncEnumerator(). Only initialize TaskSeqStateMachineData when needed. That means, we won't initialize it anymore directly in the AfterCode<_, _> section.
  • Add an InitEnumerator function, as after the previous change, we'll need to initialize from ReturnFrom as well, as Data member can now be null.

@abelbraaksma abelbraaksma force-pushed the improve-getasyncenumerator branch from 8d669f3 to 214846e Compare October 29, 2022 00:56
@abelbraaksma abelbraaksma merged commit e982267 into main Oct 29, 2022
@abelbraaksma abelbraaksma deleted the improve-getasyncenumerator branch October 29, 2022 10:41
@abelbraaksma
Copy link
Member Author

I also removed the MemberwiseClone. Will need to check if that’s an improvement.

@abelbraaksma abelbraaksma added enhancement New feature or request refactoring Cleanup, refactoring and minor fixes performance Performance questions, improvements and fixes labels Oct 29, 2022
@abelbraaksma abelbraaksma added this to the v0.1.0 milestone Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Performance questions, improvements and fixes refactoring Cleanup, refactoring and minor fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant