Multithreading 26/N: emscripten_thread_sleep - #6195
Merged
Merged
Conversation
Collaborator
Author
|
Oops, looking at the failures, this PR actually will depend on PR #6201 to land first, since |
nickshinpho
reviewed
Apr 26, 2018
|
|
||
| __pthread_testcancel(); // pthreads spec: sleep is a cancellation point, so must test if this thread is cancelled during the sleep. | ||
| emscripten_current_thread_process_queued_calls(); | ||
|
|
Contributor
There was a problem hiding this comment.
note to self: this is defined in #6201 (Multithreading 29/N)
juj
force-pushed
the
emscripten_thread_sleep
branch
from
July 21, 2018 17:21
2a19975 to
cd21b10
Compare
kripken
approved these changes
Oct 30, 2018
kripken
left a comment
Member
There was a problem hiding this comment.
lgtm, but there is a risk of confusion with emscripten_sleep which is used for async code, https://github.com/kripken/emscripten/blob/20602efb955a7c6c20865a495932427e205651d2/src/library_async.js#L61
Please document the difference in threading.h.
juj
force-pushed
the
emscripten_thread_sleep
branch
from
November 1, 2018 15:24
cd21b10 to
d9d75d9
Compare
Collaborator
Author
|
Good point - added a note and rebased to latest. |
juj
force-pushed
the
emscripten_thread_sleep
branch
from
November 1, 2018 15:26
d9d75d9 to
640a8bf
Compare
juj
force-pushed
the
emscripten_thread_sleep
branch
from
November 1, 2018 15:28
640a8bf to
d79256d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Expose internal do_sleep() as a public
emscripten_thread_sleep()function.This function is exposed to the main thread as well, since in some lock free structures the only thing one can do is to spinwait for access, even on the main thread, and doing a
emscripten_thread_sleep(0)inside such loops can improve responsiveness.In a worker thread, this function will save CPU power, since it relies on
Atomics.waitto do the waiting.