| 57 | int threadNum = 0; |
| 58 | |
| 59 | bool 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 | |
| 89 | int main() { |
| 90 | pthread_mutexattr_t attr; |
nothing calls this directly
no test coverage detected