CAPD::DynSys Library  6.0.0
capd::threading::ThreadPool Class Reference

This class realizes a simple thread pool of fixed size. More...

#include <capd/threading/ThreadPool.h>

Public Types

typedef std::unique_lock< std::mutex > UniqueLock
 
typedef std::lock_guard< std::mutex > LockGuard
 

Public Member Functions

 ThreadPool ()=delete
 Contructor takes number of threads in the pool. More...
 
 ThreadPool (const ThreadPool &)=delete
 
 ThreadPool (ThreadPool &)=delete
 
 ThreadPool (ThreadPool &&)=delete
 
 ThreadPool (unsigned noThreads)
 
void process (Task *task)
 Task submission. It should be a valid pointer to an existing instance od Task. More...
 
void interrupt ()
 This method marks a ThreadPool for interruption. The tasks already running may continue for a while (even they can complete). No new tasks will be started after call to interrupt. Submissions of new tasks to an interrupted ThreadPool leads in throwing an exception. More...
 
 ~ThreadPool ()
 
void waitUntilIdle ()
 
unsigned poolSize () const
 

Detailed Description

This class realizes a simple thread pool of fixed size.

All the threads are keeped alive until the instance of ThreadPool exists or it has been marked as interrupted.

Member Typedef Documentation

◆ LockGuard

typedef std::lock_guard<std::mutex> capd::threading::ThreadPool::LockGuard

◆ UniqueLock

typedef std::unique_lock<std::mutex> capd::threading::ThreadPool::UniqueLock

Constructor & Destructor Documentation

◆ ThreadPool() [1/5]

capd::threading::ThreadPool::ThreadPool ( )
delete

Contructor takes number of threads in the pool.

◆ ThreadPool() [2/5]

capd::threading::ThreadPool::ThreadPool ( const ThreadPool )
delete

◆ ThreadPool() [3/5]

capd::threading::ThreadPool::ThreadPool ( ThreadPool )
delete

◆ ThreadPool() [4/5]

capd::threading::ThreadPool::ThreadPool ( ThreadPool &&  )
delete

◆ ThreadPool() [5/5]

capd::threading::ThreadPool::ThreadPool ( unsigned  noThreads)
inlineexplicit

◆ ~ThreadPool()

capd::threading::ThreadPool::~ThreadPool ( )
inline

Member Function Documentation

◆ interrupt()

void capd::threading::ThreadPool::interrupt ( )
inline

This method marks a ThreadPool for interruption. The tasks already running may continue for a while (even they can complete). No new tasks will be started after call to interrupt. Submissions of new tasks to an interrupted ThreadPool leads in throwing an exception.

◆ poolSize()

unsigned capd::threading::ThreadPool::poolSize ( ) const
inline

◆ process()

void capd::threading::ThreadPool::process ( Task task)
inline

Task submission. It should be a valid pointer to an existing instance od Task.

◆ waitUntilIdle()

void capd::threading::ThreadPool::waitUntilIdle ( )
inline

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