TwiceAsNice
2019-02-18
|
#include <DispatcherThreadPool.hh>
Classes | |
class | Worker |
Public Member Functions | |
DispatcherThreadPool (int _threads=3) | |
void | init () |
~DispatcherThreadPool () | |
void | executeTask () |
bool | schedule (TaskType const &_task) |
size_t | active () const |
size_t | pending () const |
void | clear () |
bool | empty () const |
void | wait () |
void | terminate () |
DispatcherThreadPool (int _threads=3) | |
void | init () |
~DispatcherThreadPool () | |
void | executeTask () |
bool | schedule (TaskType const &_task) |
size_t | active () const |
size_t | pending () const |
void | clear () |
bool | empty () const |
void | wait () |
void | terminate () |
Protected Member Functions | |
void | createThread () |
void | createThread () |
Private Types | |
typedef Task | TaskType |
Indicates the task's type. More... | |
typedef SchedulingPolicy< TaskType > | SchedulerType |
Indicates the scheduler's type. More... | |
typedef DispatcherThreadPool< Task, SchedulingPolicy > | PoolType |
Indicates the thread pool's type. More... | |
typedef std::deque< Nice::ThreadPtr > | DispatcherThreadPoolContainer |
typedef DispatcherThreadPoolContainer::iterator | DispatcherThreadPoolContainerIterator |
typedef DispatcherThreadPoolContainer::reverse_iterator | DispatcherThreadPoolContainerReverseIterator |
typedef Task | TaskType |
Indicates the task's type. More... | |
typedef SchedulingPolicy< TaskType > | SchedulerType |
Indicates the scheduler's type. More... | |
typedef DispatcherThreadPool< Task, SchedulingPolicy > | PoolType |
Indicates the thread pool's type. More... | |
typedef std::deque< Nice::ThreadPtr > | DispatcherThreadPoolContainer |
typedef DispatcherThreadPoolContainer::iterator | DispatcherThreadPoolContainerIterator |
typedef DispatcherThreadPoolContainer::reverse_iterator | DispatcherThreadPoolContainerReverseIterator |
Private Member Functions | |
void | start () |
void | start () |
Private Attributes | |
size_t | m_maxThreads |
Nice::Atomic< size_t > | m_availThreads |
Nice::Atomic< size_t > | m_activeThreads |
SchedulerType | m_scheduler |
DispatcherThreadPoolContainer | m_workers |
IceUtil::Monitor< Nice::Mutex > | m_monitor |
Nice::Atomic< bool > | m_terminated |
Thread pool.
Thread pools are a mechanism for asynchronous and parallel processing within the same process. The pool class provides a convenient way for dispatching asynchronous tasks as functions objects. The scheduling of these tasks can be easily controlled by using customized schedulers. A task must not throw an exception.
Task | A function object which implements the operator 'void operator() (void) const'. The operator () is called by the pool to execute the task. Exceptions are ignored. |
SchedulingPolicy | A task container which determines how tasks are scheduled. It is guaranteed that this container is accessed only by one thread at a time. The scheduler shall not throw exceptions. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Indicates the thread pool's type.
|
private |
Indicates the thread pool's type.
|
private |
Indicates the scheduler's type.
|
private |
Indicates the scheduler's type.
|
private |
Indicates the task's type.
|
private |
Indicates the task's type.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the number of tasks which are currently executed.
|
inline |
Returns the number of tasks which are currently executed.
|
inline |
Removes all pending tasks from the pool's scheduler.
|
inline |
Removes all pending tasks from the pool's scheduler.
|
inlineprotected |
|
inlineprotected |
|
inline |
Indicates that there are no tasks pending.
|
inline |
Indicates that there are no tasks pending.
|
inline |
Executes a task from the scheduler. The task will be executed once only.
|
inline |
Executes a task from the scheduler. The task will be executed once only.
|
inline |
|
inline |
|
inline |
Returns the number of tasks which are ready for execution.
|
inline |
Returns the number of tasks which are ready for execution.
|
inline |
Schedules a task for asynchronous execution.
task | The task function object. It should not throw execeptions. |
|
inline |
Schedules a task for asynchronous execution.
task | The task function object. It should not throw execeptions. |
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |