MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / try_acquire_flag

Method try_acquire_flag

source/executors/thread_pool_executor.cpp:108–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool 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
123size_t idle_worker_set::find_idle_worker(size_t caller_index) noexcept {
124 if (m_approx_size.load(std::memory_order_relaxed) <= 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected