| 64 | } |
| 65 | |
| 66 | int 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 | } |
nothing calls this directly
no test coverage detected