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

Function WaitToJoin

test/pthread/test_pthread_mutex.c:59–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57int threadNum = 0;
58
59bool WaitToJoin(double time, void *userData) {
60 int threadsRunning = 0;
61 // Join all threads.
62 for (int i = 0; i < NUM_THREADS; ++i) {
63 if (thread[i]) {
64 void *status;
65 int rc = pthread_join(thread[i], &status);
66 if (rc == 0) {
67 thread[i] = 0;
68 if (threadNum < numThreadsToCreateTotal) {
69 CreateThread(i, threadNum++);
70 ++threadsRunning;
71 }
72 } else {
73 ++threadsRunning;
74 }
75 }
76 }
77 if (!threadsRunning) {
78 if (counter == numThreadsToCreateTotal)
79 emscripten_outf("All threads finished. Counter = %d as expected", counter);
80 else
81 emscripten_errf("All threads finished, but counter = %d != %d!", counter, numThreadsToCreateTotal);
82 assert(counter == 50);
83 emscripten_force_exit(0);
84 return false;
85 }
86 return true;
87}
88
89int main() {
90 pthread_mutexattr_t attr;

Callers

nothing calls this directly

Calls 4

emscripten_errfFunction · 0.85
CreateThreadFunction · 0.70
emscripten_outfFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected