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

Editorial: simplify AsyncGeneratorDrainQueue #3411

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -48676,24 +48676,19 @@ <h1>
<emu-alg>
1. Assert: _generator_.[[AsyncGeneratorState]] is ~draining-queue~.
1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]].
1. If _queue_ is empty, then
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
1. Return ~unused~.
1. Let _done_ be *false*.
1. Repeat, while _done_ is *false*,
1. Repeat,
1. If _queue_ is empty, then
Copy link
Contributor Author

@bakkot bakkot Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could also be written Repeat, while _queue_ is not empty and then put the logic inside of this If after the loop, which would maybe match the way it would be written in an implementation better? Either's fine by me.

1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
1. Return ~unused~.
1. Let _next_ be the first element of _queue_.
1. Let _completion_ be Completion(_next_.[[Completion]]).
1. If _completion_ is a return completion, then
1. Perform AsyncGeneratorAwaitReturn(_generator_).
1. Set _done_ to *true*.
1. Return ~unused~.
1. Else,
1. If _completion_ is a normal completion, then
1. Set _completion_ to NormalCompletion(*undefined*).
1. Perform AsyncGeneratorCompleteStep(_generator_, _completion_, *true*).
1. If _queue_ is empty, then
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
1. Set _done_ to *true*.
1. Return ~unused~.
</emu-alg>
</emu-clause>

Expand Down
Loading