Hermes  0.9.5-beta
Hierarchical Distributed I/O Buffering System
hermes::ThreadPool Class Reference

#include <thread_pool.h>

Public Member Functions

 ThreadPool (unsigned num_threads=std::thread::hardware_concurrency())
 
template<typename F , typename R = std::result_of_t<F && ()>>
std::future< R > run (F &&f, bool high_priority=false) const
 

Private Attributes

std::vector< std::thread > threads
 
std::queue< std::packaged_task< void()> > queue_low
 
std::queue< std::packaged_task< void()> > queue_high
 
std::mutex mutex
 
std::condition_variable condvar
 

Detailed Description

A class to represent thread pool

Constructor & Destructor Documentation

◆ ThreadPool()

hermes::ThreadPool::ThreadPool ( unsigned  num_threads = std::thread::hardware_concurrency())
inlineexplicit

construct thread pool with num_threads number of threads

Member Function Documentation

◆ run()

template<typename F , typename R = std::result_of_t<F && ()>>
std::future<R> hermes::ThreadPool::run ( F &&  f,
bool  high_priority = false 
) const
inline

a template for running thread pool

Here is the caller graph for this function:

Member Data Documentation

◆ threads

std::vector<std::thread> hermes::ThreadPool::threads
private

a vector of threads

◆ queue_low

std::queue<std::packaged_task<void()> > hermes::ThreadPool::queue_low
mutableprivate

high-priority queue

◆ queue_high

std::queue<std::packaged_task<void()> > hermes::ThreadPool::queue_high
mutableprivate

low-priority queue

◆ mutex

std::mutex hermes::ThreadPool::mutex
mutableprivate

mutex lock

◆ condvar

std::condition_variable hermes::ThreadPool::condvar
mutableprivate

conditional variable


The documentation for this class was generated from the following file: