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

Method enqueue

source/executors/thread_pool_executor.cpp:557–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555}
556
557void thread_pool_executor::enqueue(concurrencpp::task task) {
558 const auto this_worker = details::s_tl_thread_pool_data.this_worker;
559 const auto this_worker_index = details::s_tl_thread_pool_data.this_thread_index;
560
561 if (this_worker != nullptr && this_worker->appears_empty()) {
562 return this_worker->enqueue_local(task);
563 }
564
565 const auto idle_worker_pos = m_idle_workers.find_idle_worker(this_worker_index);
566 if (idle_worker_pos != static_cast<size_t>(-1)) {
567 return m_workers[idle_worker_pos].enqueue_foreign(task);
568 }
569
570 if (this_worker != nullptr) {
571 return this_worker->enqueue_local(task);
572 }
573
574 const auto next_worker = m_round_robin_cursor.fetch_add(1, std::memory_order_relaxed) % m_workers.size();
575 m_workers[next_worker].enqueue_foreign(task);
576}
577
578void thread_pool_executor::enqueue(std::span<concurrencpp::task> tasks) {
579 if (details::s_tl_thread_pool_data.this_worker != nullptr) {

Callers

nothing calls this directly

Calls 8

enqueueFunction · 0.85
appears_emptyMethod · 0.80
find_idle_workerMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
enqueue_localMethod · 0.45
enqueue_foreignMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected