Recursive function to spawn all worker threads in parallel
| 301 | |
| 302 | // Recursive function to spawn all worker threads in parallel |
| 303 | static void recursive_spawn_worker_thread(threadpool_data* impl, std::size_t index, std::size_t threads) |
| 304 | { |
| 305 | // If we are down to one thread, go to the worker main loop |
| 306 | if (threads == 1) |
| 307 | worker_thread(impl, index); |
| 308 | else { |
| 309 | // Split thread range into 2 sub-ranges |
| 310 | std::size_t mid = index + threads / 2; |
| 311 | |
| 312 | // Spawn a thread for half of the range |
| 313 | impl->thread_data[mid].handle = std::thread(recursive_spawn_worker_thread, impl, mid, threads - threads / 2); |
| 314 | #ifdef BROKEN_JOIN_IN_DESTRUCTOR |
| 315 | impl->thread_data[mid].handle.detach(); |
| 316 | #endif |
| 317 | |
| 318 | // Tail-recurse to handle our half of the range |
| 319 | recursive_spawn_worker_thread(impl, index, threads / 2); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | } // namespace detail |
| 324 |
nothing calls this directly
no test coverage detected