This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@devoncarew Is this something you can help review, or help identify a reviewer, as it appears @mraleph might not be available. |
devoncarew
reviewed
Jul 19, 2024
Unfortunately I'm not familiar with this package; @mraleph will be back in a week (@mkustermann - the other likely reviewer - is OOO at the moment as well). |
mraleph
suggested changes
Jul 30, 2024
@mraleph I've updated the documentation. Can you please take another look when you get a chance? |
mraleph
approved these changes
Aug 1, 2024
devoncarew
pushed a commit
to dart-lang/labs
that referenced
this pull request
Sep 23, 2024
* Add closed state to Mailbox * Update documentation
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative solution to the same problem described in #25 for sass/dart-sass#2279
On high level we have following logic in dart-sass, and we need a way to reliable stop the loop via mailbox:
Main Isolate:
Worker Isolate:
First,
Isolate.kill(priority: Isolate.immediate)
won't work whenmailbox.take()
is blocking. So, instead we callIsolate.kill()
first, and then send an empty message to signal the stopping. However, because the sending of empty message can fail, and then depending on the event loop timing, the worker isolate may process the isolate kill event before entering the loop one more time, which works as expected (killed before next iteration of loop); or it may get to the next iteration too quickly before the isolate kill event is processed, and thus cause the VM to lock up because the nextmailbox.take()
blocks the processing of kill event, causing the isolate to be appear non-responsive.Adding
close
method as designed in this PR will allow us to do:Main Isolate:
Worker Isolate:
Because
mailbox.close()
is guaranteed to deliver the signal viaStateError
on the ongoing or nextmailbox.take()
, we don't have the problem of failing to send empty message.