| 67 | #endif |
| 68 | |
| 69 | static void *pthread_worker(void *arg) { |
| 70 | pthread_worker_arg_t *wa = arg; |
| 71 | while (WP_TRUE) { |
| 72 | int idx = atomic_fetch_add_explicit(wa->next_idx, WP_STEP, memory_order_relaxed); |
| 73 | if (idx >= wa->count) { |
| 74 | break; |
| 75 | } |
| 76 | wa->fn(idx, wa->ctx); |
| 77 | } |
| 78 | /* This thread ends here: hand its pending memory-class deltas to the |
| 79 | * shared counters, so the phase mark that follows the join is exact. */ |
| 80 | cbm_mem_class_flush_thread(); |
| 81 | return NULL; |
| 82 | } |
| 83 | |
| 84 | #if defined(CBM_MEMWASTE) && CBM_MEMWASTE |
| 85 | static void run_pthreads_counted(int count, cbm_parallel_fn fn, void *ctx, int nworkers, |
nothing calls this directly
no test coverage detected