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

Method drain_queue

source/executors/thread_pool_executor.cpp:343–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343bool thread_pool_worker::drain_queue() {
344 std::unique_lock<std::mutex> lock(m_lock);
345 if (!wait_for_task(lock)) {
346 return false;
347 }
348
349 assert(lock.owns_lock());
350 assert(!m_public_queue.empty() || m_abort);
351
352 m_task_found_or_abort.store(false, std::memory_order_relaxed);
353
354 if (m_abort) {
355 m_idle = true;
356 return false;
357 }
358
359 assert(m_private_queue.empty());
360 std::swap(m_private_queue, m_public_queue); // reuse underlying allocations.
361 lock.unlock();
362
363 return drain_queue_impl();
364}
365
366void thread_pool_worker::work_loop() {
367 s_tl_thread_pool_data.this_worker = this;

Callers

nothing calls this directly

Calls 3

owns_lockMethod · 0.80
unlockMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected