1#ifndef BVH_V2_THREAD_POOL_H 
    2#define BVH_V2_THREAD_POOL_H 
    6#include <condition_variable> 
   15    using Task = std::function<void(
size_t)>;
 
   35    inline void start(
size_t);
 
 
   50        std::unique_lock<std::mutex> lock(
mutex_);
 
 
   57    std::unique_lock<std::mutex> lock(
mutex_);
 
 
   65            std::unique_lock<std::mutex> lock(
pool->mutex_);
 
   66            pool->avail_.wait(lock, [
pool] { 
return pool->should_stop_ || !
pool->tasks_.empty(); });
 
   67            if (
pool->should_stop_ && 
pool->tasks_.empty())
 
   69            task = std::move(
pool->tasks_.front());
 
   75            std::unique_lock<std::mutex> lock(
pool->mutex_);
 
   78        pool->done_.notify_one();
 
 
   84        thread_count = std::max(1u, std::thread::hardware_concurrency());
 
 
   91        std::unique_lock<std::mutex> lock(
mutex_);
 
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
std::vector< std::thread > threads_
 
static void worker(ThreadPool *, size_t)
 
size_t get_thread_count() const
 
std::queue< Task > tasks_
 
std::condition_variable avail_
 
std::condition_variable done_
 
ThreadPool(size_t thread_count=0)
Creates a thread pool with the given number of threads (a value of 0 tries to autodetect the number o...
 
std::function< void(size_t)> Task