MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / WaitingThread

Function WaitingThread

test/pthread/test_futex_wake_all.c:33–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void *WaitingThread(void *arg) {
34 // Last waiting thread creates the waking thread - this simplifies mutual synchronization needs
35 if ((long)arg == NUM_THREADS-1) {
36 pthread_create(&wakingThread, 0, WakingThread, 0);
37 }
38
39 // Each waiting thread waits until wake thread changes the value at the wait address
40 while (emscripten_atomic_load_u32(&futexVal) == 0) {
41 emscripten_futex_wait(&futexVal, 0, INFINITY);
42 }
43
44 // Tally up the number of awoken threads - last one to wake up signals test success
45 uint32_t old = emscripten_atomic_add_u32(&numAwoken, 1);
46 if (old + 1 == NUM_THREADS) {
47 emscripten_force_exit(0);
48 }
49
50 return 0;
51}
52
53int main() {
54 for (intptr_t i = 0; i < NUM_THREADS; ++i) {

Callers

nothing calls this directly

Calls 3

emscripten_futex_waitFunction · 0.50

Tested by

no test coverage detected