AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::ThreadPool Class Reference

Thread pool utility class. More...

#include <threadPool.hpp>

+ Collaboration diagram for anch::ThreadPool:

Public Member Functions

 ThreadPool (uint32_t maxThreads=0)
 
virtual ~ThreadPool ()
 
void start ()
 
void stop ()
 
template<typename R, typename P = std::ratio<1>>
void awaitTermination (std::chrono::duration< R, P > duration)
 
template<typename Func, typename... Args>
void add (Func function, Args... args)
 

Detailed Description

Thread pool utility class.

Number of thread can be parameterized in constructor. If not set, the maximum number of thread will be equal to the number of processor or 1.

Every thread which will be run by this way will be detach. They will be not joinable.
Thread can be retrieve through event mechanism or by specific implementation in thread function.

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ ThreadPool()

anch::ThreadPool::ThreadPool ( uint32_t maxThreads = 0)

ThreadPool constructor

Parameters
maxThreadsthe maximum number of alive threads (default number of processor or 1 if not defined)

◆ ~ThreadPool()

virtual anch::ThreadPool::~ThreadPool ( )
virtual

ThreadPool destructor

Member Function Documentation

◆ add()

template<typename Func, typename... Args>
void anch::ThreadPool::add ( Func function,
Args... args )

Add a new thread in queue

Parameters
functionthe function which will be call in a separated thread
argsthe function arguments

◆ awaitTermination()

template<typename R, typename P = std::ratio<1>>
void anch::ThreadPool::awaitTermination ( std::chrono::duration< R, P > duration)

Await thread pool termination

Parameters
durationthe maximum duration to wait. If <1 wait indefinitly. Default std::chrono::seconds(-1) .

◆ start()

void anch::ThreadPool::start ( )

Start executing threads in queue

◆ stop()

void anch::ThreadPool::stop ( )

Stop executing threads in queue


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