| 106 | } |
| 107 | |
| 108 | bool idle_worker_set::try_acquire_flag(size_t index) noexcept { |
| 109 | const auto worker_status = m_idle_flags[index].flag.load(std::memory_order_relaxed); |
| 110 | if (worker_status == status::active) { |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | const auto before = m_idle_flags[index].flag.exchange(status::active, std::memory_order_relaxed); |
| 115 | const auto swapped = (before == status::idle); |
| 116 | if (swapped) { |
| 117 | m_approx_size.fetch_sub(1, std::memory_order_relaxed); |
| 118 | } |
| 119 | |
| 120 | return swapped; |
| 121 | } |
| 122 | |
| 123 | size_t idle_worker_set::find_idle_worker(size_t caller_index) noexcept { |
| 124 | if (m_approx_size.load(std::memory_order_relaxed) <= 0) { |
nothing calls this directly
no outgoing calls
no test coverage detected