matador::thread_pool Class Reference

#include <thread_pool.hpp>

Public Member Functions

 thread_pool (std::size_t size)
 
template<typename F >
void schedule (F func)
 
void add_task ()
 
std::size_t size () const
 
void shutdown ()
 
void wait ()
 
std::size_t pending ()
 

Detailed Description

Simple thread pool class. The pool consists of a given number of threads and a queue of tasks to be executed.

Constructor & Destructor Documentation

◆ thread_pool()

matador::thread_pool::thread_pool ( std::size_t  size)
explicit

Creating a new thread pool with given numbers of threads.

Parameters
sizeNumber of provided threads.

Member Function Documentation

◆ add_task()

void matador::thread_pool::add_task ( )

Adds a new task to the thread queue.

◆ pending()

std::size_t matador::thread_pool::pending ( )

Returns the number of pending tasks.

Returns
Number of pending tasks.

◆ schedule()

template<typename F >
void matador::thread_pool::schedule ( func)
inline

Push a task into the thread pool to be executed once a thread is available

Template Parameters
FType of threaded function
Parameters
funcFunction to be executed in next available thread.

◆ shutdown()

void matador::thread_pool::shutdown ( )

Shuts the thread pool down.

◆ size()

std::size_t matador::thread_pool::size ( ) const

Returns the number of available threads.

Returns
Number of threads.

◆ wait()

void matador::thread_pool::wait ( )

Waits until all threads are finished.


The documentation for this class was generated from the following file:
  • matador/utils/thread_pool.hpp