-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Update docs about emscripten_exit_with_live_runtime and pthreads #8167
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ops, sorry, this has slipped my attention.
Originally the design was indeed to do just like what happens with the main thread: the main/pthread_main yields/unwinds out, but remains alive for later event-based calls into it.
Now reading the docs wording, I find that the original function name
emscripten_exit_with_live_runtime()
is maybe a bit misleading: saying that it both "exits" and also keeps a "live runtime" seem to contradict each other.Here
In a multithreaded application, this just exits the current thread
the wordexit
might be understood by the reader to mean the same as in quit, stop or terminate. But of course the thread (in web, thread == the Worker) is kept alive, and it will execute any events that are passed to it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should probably replace "exits" here with something closer to "unwinds"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to draw a distinction between "thread" here and "worker". In the current models workers basically never exit and never stop responding to message, but they can stop hosting a pthread and be returned the pool. "emscripten_exit_with_live_runtime" means we continue to host a pthread on the worker.
I'm not sure if other types of worker (i.e. audio worklets) have this concept since IIRC they can already never die to be recycled? Perhaps
emscripten_exit_with_live_runtime()
should error if called from another type of worker or that is not hosting a pthread (including the main pthread that that set)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation of
emscripten_exit_with_live_runtime()
is though compatible with Audio Worklets and Wasm Workers in that they can be used to achieve the unwind effect. So we might let users do that to be able to reuse/share code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So under Audio Worklets or Wasm Workers this is exactly the same as
emscripten_unwind_to_js_event_loop
?May be worth mentioning that here too.