-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add emscripten_queue_microtask() API #25741
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
base: main
Are you sure you want to change the base?
Changes from all commits
91daa78
5b6c25d
27918d7
d18fa99
f87c2db
5b30d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright 2025 The Emscripten Authors. All rights reserved. | ||
| * Emscripten is available under two separate licenses, the MIT license and the | ||
| * University of Illinois/NCSA Open Source License. Both these licenses can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| // Test emscripten_queue_microtask() behavior | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <emscripten.h> | ||
| #include <emscripten/eventloop.h> | ||
|
|
||
| void cb(void *userData) { | ||
| printf("cb\n"); | ||
| assert(userData == (void*)42); | ||
| emscripten_force_exit(0); | ||
| } | ||
|
|
||
| int main() { | ||
| emscripten_queue_microtask(cb, (void*)42); | ||
| emscripten_exit_with_live_runtime(); | ||
| return 99; // We won't reach here, but return non-zero value to guard against refactors that might exit() with this value. | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5024,6 +5024,13 @@ def test_emscripten_request_animation_frame_loop(self): | |
| def test_request_animation_frame(self): | ||
| self.btest_exit('test_request_animation_frame.c') | ||
|
|
||
| @parameterized({ | ||
| '': ([],), | ||
| 'proxy_to_pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],), | ||
| }) | ||
| def test_emscripten_queue_microtask(self, flags): | ||
| self.btest_exit('emscripten_queue_microtask.c', cflags=cflags) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test can run on node too so maybe can live in test_other.py? But maybe we want to specifically test in the browser? See https://nodejs.org/api/globals.html#queuemicrotaskcallback
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, did you have a mechanism for running browser suite with 'node' as the browser executable? I recall glancing over something along those lines. Otherwise I presume we could duplicate the test in other + browser?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do The current method is to just duplicate the tests that it makes sense to duplicate. |
||
|
|
||
| @requires_shared_array_buffer | ||
| def test_emscripten_set_timeout(self): | ||
| self.btest_exit('emscripten_set_timeout.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD']) | ||
|
|
||
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.
Move to
libeventloops.js?