Libosmium  2.12.2
Fast and flexible C++ library for working with OpenStreetMap data
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
osmium::thread::Pool Class Reference

#include <pool.hpp>

Collaboration diagram for osmium::thread::Pool:
Collaboration graph
[legend]

Classes

class  thread_joiner
 

Public Member Functions

void shutdown_all_workers ()
 
 ~Pool ()
 
size_t queue_size () const
 
bool queue_empty () const
 
template<typename TFunction >
std::future< typename std::result_of< TFunction()>::type > submit (TFunction &&func)
 

Static Public Member Functions

static Poolinstance ()
 

Static Public Attributes

static constexpr int default_num_threads = 0
 

Private Member Functions

void worker_thread ()
 
 Pool (int num_threads, size_t max_queue_size)
 

Private Attributes

osmium::thread::Queue< function_wrapperm_work_queue
 
std::vector< std::thread > m_threads
 
thread_joiner m_joiner
 
int m_num_threads
 

Detailed Description

Thread pool.

Constructor & Destructor Documentation

◆ Pool()

osmium::thread::Pool::Pool ( int  num_threads,
size_t  max_queue_size 
)
inlineexplicitprivate

Create thread pool with the given number of threads. If num_threads is 0, the number of threads is read from the environment variable OSMIUM_POOL_THREADS. The default value in that case is -2.

If the number of threads is a negative number, it will be set to the actual number of cores on the system plus the given number, ie it will leave a number of cores unused.

In all cases the minimum number of threads in the pool is 1.

◆ ~Pool()

osmium::thread::Pool::~Pool ( )
inline

Member Function Documentation

◆ instance()

static Pool& osmium::thread::Pool::instance ( )
inlinestatic

◆ queue_empty()

bool osmium::thread::Pool::queue_empty ( ) const
inline

◆ queue_size()

size_t osmium::thread::Pool::queue_size ( ) const
inline

◆ shutdown_all_workers()

void osmium::thread::Pool::shutdown_all_workers ( )
inline

◆ submit()

template<typename TFunction >
std::future<typename std::result_of<TFunction()>::type> osmium::thread::Pool::submit ( TFunction &&  func)
inline

◆ worker_thread()

void osmium::thread::Pool::worker_thread ( )
inlineprivate

Member Data Documentation

◆ default_num_threads

constexpr int osmium::thread::Pool::default_num_threads = 0
static

◆ m_joiner

thread_joiner osmium::thread::Pool::m_joiner
private

◆ m_num_threads

int osmium::thread::Pool::m_num_threads
private

◆ m_threads

std::vector<std::thread> osmium::thread::Pool::m_threads
private

◆ m_work_queue

osmium::thread::Queue<function_wrapper> osmium::thread::Pool::m_work_queue
private

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