client-cpp  0.10.0
kaa::ThreadPool Class Reference

#include <ThreadPool.hpp>

+ Inheritance diagram for kaa::ThreadPool:
+ Collaboration diagram for kaa::ThreadPool:

Public Member Functions

 ThreadPool (std::size_t workerCount=DEFAULT_WORKER_NUMBER)
 
 ~ThreadPool ()
 
virtual void add (const ThreadPoolTask &task)
 Add a task for execution. More...
 
virtual void awaitTermination (std::size_t seconds)
 Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs. More...
 
virtual void shutdown ()
 Initiates a shutdown in which previously added tasks are executed, but no new tasks will be accepted. More...
 
virtual void shutdownNow ()
 Initiates a shutdown in which all executing tasks will complete. Pending tasks will be declined. More...
 
- Public Member Functions inherited from kaa::IThreadPool
virtual ~IThreadPool ()
 

Static Public Attributes

static const std::size_t DEFAULT_WORKER_NUMBER = 1
 

Friends

class Worker
 

Detailed Description

Definition at line 29 of file ThreadPool.hpp.

Constructor & Destructor Documentation

kaa::ThreadPool::ThreadPool ( std::size_t  workerCount = DEFAULT_WORKER_NUMBER)
kaa::ThreadPool::~ThreadPool ( )

Member Function Documentation

virtual void kaa::ThreadPool::add ( const ThreadPoolTask task)
virtual

Add a task for execution.

Parameters
taskThe task to add.
Exceptions
std::invalid_argumentThe task object is invalid, i.e. empty.
std::logic_errorThe thread pool is shut down.

Implements kaa::IThreadPool.

virtual void kaa::ThreadPool::awaitTermination ( std::size_t  seconds)
virtual

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs.

Note
Call only after shutdown().
Parameters
secondsThe maximum time in seconds to wait.
Exceptions
std::logic_errorThe method was called without shutdown().

Implements kaa::IThreadPool.

virtual void kaa::ThreadPool::shutdown ( )
virtual

Initiates a shutdown in which previously added tasks are executed, but no new tasks will be accepted.

Implements kaa::IThreadPool.

virtual void kaa::ThreadPool::shutdownNow ( )
virtual

Initiates a shutdown in which all executing tasks will complete. Pending tasks will be declined.

Implements kaa::IThreadPool.

Friends And Related Function Documentation

friend class Worker
friend

Definition at line 30 of file ThreadPool.hpp.

Member Data Documentation

const std::size_t kaa::ThreadPool::DEFAULT_WORKER_NUMBER = 1
static

Definition at line 44 of file ThreadPool.hpp.


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