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

Function main

test/pthread/test_pthread_create.c:66–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66int main() {
67 // Create initial threads.
68 for (int i = 0; i < NUM_THREADS; ++i)
69 CreateThread(i);
70
71 int numThreadsToCreate = 1000;
72
73 // Join all threads and create more.
74 while (numThreadsToCreate > 0) {
75 for (int i = 0; i < NUM_THREADS; ++i) {
76 if (thread[i]) {
77 intptr_t status;
78 int rc = pthread_join(thread[i], (void**)&status);
79 assert(rc == 0);
80 emscripten_errf("Main: Joined thread idx %d (param %d) with status %d", i, global_shared_data[i], (int)status);
81 assert(status == N);
82 thread[i] = 0;
83 if (numThreadsToCreate > 0) {
84 --numThreadsToCreate;
85 CreateThread(i);
86 }
87 }
88 }
89 }
90
91 printf("All threads joined.\n");
92 return 0;
93}

Callers

nothing calls this directly

Calls 4

emscripten_errfFunction · 0.85
printfFunction · 0.85
CreateThreadFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected