Allow emscripten_atomic_wait_suspending to return synchronously#26947
Open
sbc100 wants to merge 1 commit into
Open
Allow emscripten_atomic_wait_suspending to return synchronously#26947sbc100 wants to merge 1 commit into
sbc100 wants to merge 1 commit into
Conversation
sbc100
commented
May 14, 2026
aece5ac to
3f54471
Compare
sbc100
commented
May 14, 2026
f2b3b85 to
8868476
Compare
Collaborator
Author
|
I have a nice followup to which I think makes this solution nicer: f5cc8ee |
Member
|
Sounds reasonable. |
Collaborator
Author
|
@tlively Do you think this approach makes sense then? i.e. the version where we return a promise and only suspend sometimes? If so, are you OK landing this change? (with the "await_unchecked") as a separate followup? |
Collaborator
Author
|
Actually maybe lets just land #26954 first |
sbc100
added a commit
that referenced
this pull request
May 15, 2026
This works with ASYNCIFY like the existing `emscripten_promise_await` but is a lot simpler since it only handles the fulfilled case. In this case we can simple return the result directly without needing to allocate a `em_promise_result_t` struct to deal with the out param (i.e. no memory access needed). This can be useful in cases where we don't want to handle the rejections case. Split out from #26947
8868476 to
c5a41e9
Compare
Collaborator
Author
|
OK, this is now rebase on top of #26954. PTAL! |
c5a41e9 to
5e69766
Compare
Followup to the initial version landed in emscripten-core#26941
5e69766 to
9cd0cdb
Compare
tlively
reviewed
May 15, 2026
| void _emscripten_thread_notify(pthread_t thread); | ||
|
|
||
| // Internal promise-returning API used to implement | ||
| // emscripten_atomic_wait_syspending. |
Member
There was a problem hiding this comment.
Suggested change
| // emscripten_atomic_wait_syspending. | |
| // emscripten_atomic_wait_suspending. |
| 'MAX_WEBGL_VERSION': 0, | ||
| 'BUILD_AS_WORKER': 1, | ||
| 'LINK_AS_CXX': 1, | ||
| 'SHARED_MEMORY': 0, |
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.
Followup to the initial version landed in #26941. This version of the code allows for reporting of synchronous results without actually suspending.
The implementation of
emscripten_atomic_wait_suspendingis not in libc, and it works by first calling a non-JSPI function which can return a promise, or a sync result. Then, only in the case that a promise is returned do we actually need to suspend using a JSPI call.