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

Separate initial and finished states for enumerable and async-enumerables #76841

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jan 21, 2025

For enumerables, the problem was introduced recently.
For async-enumerables, the problem existed from the beginning.

Old

  • Iterator: N <= -3 (finalize states), -2 (initial for enumerable, finished), -1 (running), 0 (initial for enumerator, ie. start of method), N > 0 (resumable states for 'yield return')
  • Async-iterator: N <= -4 (resumable states for yield return) -3 (initial for enumerator) -2 (initial for enumerable, finished) -1 (running) N >= 0 (resumable states for await)
  • Async: N <= -3 (vestigial finalizer states in VB) -2 (finished) -1 (running) N >= 0 (resumable states for await)

Goal

Separate the finished and initial states

Changes

  • Async-iterator initial state (ie. indicating start of method) is now -4
  • Iterator and async-iterator finish on -3
  • No changes to async

New

  • Iterator: N <= -4 (finalize states), -3 (finished), -2 (initial for enumerable), -1 (running), 0 (initial for enumerator, ie. start of method), N > 0 (resumable states for 'yield return')
  • Async-iterator: N <= -5 (resumable states for yield return) -4 (initial for enumerator) -3 (finished) -2 (initial for enumerable) -1 (running) N >= 0 (resumable states for await)

Questions

  • I debated changing the finished state for async machines too (from -2 to -3). That would create some alignment across state machine kinds.

@jcouv jcouv self-assigned this Jan 21, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant