| 21 | struct RunThread |
| 22 | { |
| 23 | void operator()(exec::static_thread_pool& pool, |
| 24 | std::size_t total_scheds, |
| 25 | std::size_t tid, |
| 26 | std::barrier<>& barrier, |
| 27 | #ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE |
| 28 | std::span<char> buffer, |
| 29 | #endif |
| 30 | std::atomic<bool>& stop, |
| 31 | exec::numa_policy numa) |
| 32 | { |
| 33 | int numa_node = numa.thread_index_to_node(tid); |
| 34 | numa.bind_to_node(numa_node); |
| 35 | exec::nodemask mask{}; |
| 36 | mask.set(static_cast<std::size_t>(numa_node)); |
| 37 | auto scheduler = pool.get_constrained_scheduler(&mask); |
| 38 | std::mutex mut; |
| 39 | std::condition_variable cv; |
| 40 | while (true) |
| 41 | { |
| 42 | barrier.arrive_and_wait(); |
| 43 | if (stop.load()) |
| 44 | { |
| 45 | break; |
| 46 | } |
| 47 | #ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE |
| 48 | pmr::monotonic_buffer_resource resource{buffer.data(), |
| 49 | buffer.size(), |
| 50 | pmr::null_memory_resource()}; |
| 51 | pmr::polymorphic_allocator<char> alloc(&resource); |
| 52 | auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism()); |
| 53 | std::size_t scheds = end - start; |
| 54 | std::atomic<std::size_t> counter{scheds}; |
| 55 | auto env = stdexec::prop{stdexec::get_allocator, alloc}; |
| 56 | while (scheds) |
| 57 | { |
| 58 | exec::start_detached(stdexec::schedule(scheduler) |
| 59 | | stdexec::then( |
| 60 | [&] |
| 61 | { |
| 62 | auto prev = counter.fetch_sub(1); |
| 63 | if (prev == 1) |
| 64 | { |
| 65 | std::lock_guard lock{mut}; |
| 66 | cv.notify_one(); |
| 67 | } |
| 68 | }), |
| 69 | env); |
| 70 | --scheds; |
| 71 | } |
| 72 | #else |
| 73 | auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism()); |
| 74 | std::size_t scheds = end - start; |
| 75 | std::atomic<std::size_t> counter{scheds}; |
| 76 | while (scheds) |
| 77 | { |
| 78 | exec::start_detached(stdexec::schedule(scheduler) |
| 79 | | stdexec::then( |
| 80 | [&] |
nothing calls this directly
no test coverage detected