-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Implement emscripten_promise_all_settled
in promise.h
#19152
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
Conversation
This is like `emscripten_promise_all`, but always fulfills and separately reports whether each input promise is fulfilled or rejected.
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
src/library_promise.js
Outdated
promise: Promise.allSettled(promises).then((results) => { | ||
if (resultBuf) { | ||
for (var i = 0; i < size; i++) { | ||
let baseOffset = i * {{{ C_STRUCTS.em_settled_result_t.__size__ }}}; |
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 don't think we using let
yet in our library code. Can you stick to var
?
Any ideas for how to work around this closure error?
|
I just decided to suppress it for now. LMK if there's a better solution. |
Yikes, it looks like some build modes remove the newline after the suppression comment, causing a new error.
@sbc100, any ideas for workarounds? |
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.
TIL about allSettled...
I've not seen that before from the |
src/library_promise.js
Outdated
{{{ makeSetValue('resultBuf', 'resultOffset', 'reject', 'i32') }}}; | ||
// Closure can't type `reason` in some contexts | ||
/** @suppress {checkTypes} */ | ||
{{{ makeSetValue('resultBuf', 'valueOffset', 'results[i].reason', '*') }}}; |
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.
So these promises only ever get rejected or fullfilled with Numbers? What happens if one of them is rejected to fulfilled with something that is not a number?
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.
Yeah, they're always fulfilled or rejected with pointers because the fulfill values and reject reasons are always represented as void*
in the C API.
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 think you can do something like this: var reason = /** @type {number} */ results[i].reason;
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.
Is there a good way to generalize that for wasm64?
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 use number
for pointer in wasm64 and wasm32 so it should just work.
This is like
emscripten_promise_all
, but always fulfills and separatelyreports whether each input promise is fulfilled or rejected.