| 516 | } |
| 517 | |
| 518 | thread_pool_executor::thread_pool_executor(std::string_view pool_name, |
| 519 | size_t pool_size, |
| 520 | std::chrono::milliseconds max_idle_time, |
| 521 | const std::function<void(std::string_view thread_name)>& thread_started_callback, |
| 522 | const std::function<void(std::string_view thread_name)>& thread_terminated_callback) : |
| 523 | derivable_executor<concurrencpp::thread_pool_executor>(pool_name), |
| 524 | m_round_robin_cursor(0), m_idle_workers(pool_size), m_abort(false) { |
| 525 | m_workers.reserve(pool_size); |
| 526 | |
| 527 | for (size_t i = 0; i < pool_size; i++) { |
| 528 | m_workers.emplace_back(*this, i, pool_size, max_idle_time, thread_started_callback, thread_terminated_callback); |
| 529 | } |
| 530 | |
| 531 | for (size_t i = 0; i < pool_size; i++) { |
| 532 | m_idle_workers.set_idle(i); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | thread_pool_executor::~thread_pool_executor() = default; |
| 537 | |