Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
bvh::v2::ThreadPool Class Reference

Definition at line 13 of file thread_pool.h.

Public Types

using Task = std::function< void(size_t)>
 

Public Member Functions

 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 of threads and uses that as a thread count).
 
 ~ThreadPool ()
 
size_t get_thread_count () const
 
void push (Task &&fun)
 
void wait ()
 

Private Member Functions

void join ()
 
void start (size_t)
 
void stop ()
 

Static Private Member Functions

static void worker (ThreadPool *, size_t)
 

Private Attributes

std::condition_variable avail_
 
int busy_count_ = 0
 
std::condition_variable done_
 
std::mutex mutex_
 
bool should_stop_ = false
 
std::queue< Tasktasks_
 
std::vector< std::thread > threads_
 

#include <bvh/v2/thread_pool.h>

Member Typedef Documentation

◆ Task

using bvh::v2::ThreadPool::Task = std::function<void(size_t)>

Definition at line 15 of file thread_pool.h.

Constructor & Destructor Documentation

◆ ThreadPool()

bvh::v2::ThreadPool::ThreadPool ( size_t  thread_count = 0)
inline

Creates a thread pool with the given number of threads (a value of 0 tries to autodetect the number of threads and uses that as a thread count).

Definition at line 19 of file thread_pool.h.

◆ ~ThreadPool()

bvh::v2::ThreadPool::~ThreadPool ( )
inline

Definition at line 21 of file thread_pool.h.

Member Function Documentation

◆ get_thread_count()

size_t bvh::v2::ThreadPool::get_thread_count ( ) const
inline

Definition at line 30 of file thread_pool.h.

◆ join()

void bvh::v2::ThreadPool::join ( )
inlineprivate

Definition at line 97 of file thread_pool.h.

◆ push()

void bvh::v2::ThreadPool::push ( Task &&  fun)
inline

Definition at line 48 of file thread_pool.h.

◆ start()

void bvh::v2::ThreadPool::start ( size_t  thread_count)
inlineprivate

Definition at line 82 of file thread_pool.h.

◆ stop()

void bvh::v2::ThreadPool::stop ( )
inlineprivate

Definition at line 89 of file thread_pool.h.

◆ wait()

void bvh::v2::ThreadPool::wait ( )
inline

Definition at line 56 of file thread_pool.h.

◆ worker()

void bvh::v2::ThreadPool::worker ( ThreadPool pool,
size_t  thread_id 
)
inlinestaticprivate

Definition at line 61 of file thread_pool.h.

Member Data Documentation

◆ avail_

std::condition_variable bvh::v2::ThreadPool::avail_
private

Definition at line 43 of file thread_pool.h.

◆ busy_count_

int bvh::v2::ThreadPool::busy_count_ = 0
private

Definition at line 39 of file thread_pool.h.

◆ done_

std::condition_variable bvh::v2::ThreadPool::done_
private

Definition at line 44 of file thread_pool.h.

◆ mutex_

std::mutex bvh::v2::ThreadPool::mutex_
private

Definition at line 41 of file thread_pool.h.

◆ should_stop_

bool bvh::v2::ThreadPool::should_stop_ = false
private

Definition at line 40 of file thread_pool.h.

◆ tasks_

std::queue<Task> bvh::v2::ThreadPool::tasks_
private

Definition at line 45 of file thread_pool.h.

◆ threads_

std::vector<std::thread> bvh::v2::ThreadPool::threads_
private

Definition at line 42 of file thread_pool.h.

  • geom/geom/inc/bvh/v2/thread_pool.h