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

Method shutdown

source/executors/thread_pool_executor.cpp:480–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480void thread_pool_worker::shutdown() {
481 assert(!m_atomic_abort.load(std::memory_order_relaxed));
482 m_atomic_abort.store(true, std::memory_order_relaxed);
483
484 {
485 std::unique_lock<std::mutex> lock(m_lock);
486 m_abort = true;
487 }
488
489 m_task_found_or_abort.store(true, std::memory_order_relaxed); // make sure the store is finished before notifying the worker.
490
491 m_semaphore.release();
492
493 if (m_thread.joinable()) {
494 m_thread.join();
495 }
496
497 decltype(m_public_queue) public_queue;
498 decltype(m_private_queue) private_queue;
499
500 {
501 std::unique_lock<std::mutex> lock(m_lock);
502 public_queue = std::move(m_public_queue);
503 private_queue = std::move(m_private_queue);
504 }
505
506 public_queue.clear();
507 private_queue.clear();
508}
509
510std::chrono::milliseconds thread_pool_worker::max_worker_idle_time() const noexcept {
511 return m_max_idle_time;

Callers

nothing calls this directly

Calls 4

releaseMethod · 0.80
joinableMethod · 0.80
joinMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected