| 555 | } |
| 556 | |
| 557 | void 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 | |
| 578 | void thread_pool_executor::enqueue(std::span<concurrencpp::task> tasks) { |
| 579 | if (details::s_tl_thread_pool_data.this_worker != nullptr) { |
nothing calls this directly
no test coverage detected