Reference | Class List | Member Functions | Typedefs | File List |
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.
A pool is DefaultConstructible, CopyConstructible and Assignable. It has reference semantics; all copies of the same pool are equivalent and interchangeable. All operations on a pool except assignment are strongly thread safe or sequentially consistent; that is, the behavior of concurrent calls is as if the calls have been issued sequentially in an unspecified order.
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. |
Scheduling policies: fifo_scheduler, lifo_scheduler, prio_scheduler
Definition at line 73 of file pool.hpp.
Public Types | |
typedef SchedulingPolicy< task_type > | scheduler_type |
typedef SizePolicyController< pool_core_type > | size_controller_type |
typedef SizePolicy< pool_core_type > | size_policy_type |
typedef Task | task_type |
Public Member Functions | |
size_t | active () const |
void | clear () |
bool | empty () const |
size_t | pending () const |
bool | schedule (task_type const &task) |
size_t | size () const |
size_controller_type | size_controller () |
thread_pool (size_t initial_threads=0) | |
bool | wait (xtime const ×tamp, size_t task_threshold=0) const |
void | wait (size_t task_threshold=0) const |
|
Indicates the scheduler's type.
|
|
|
|
|
|
Indicates the task's type.
|
|
Constructor.
|
|
Returns the number of tasks which are currently executed.
|
|
Removes all pending tasks from the pool's scheduler. |
|
Indicates that there are no tasks pending.
|
|
Returns the number of tasks which are ready for execution.
|
|
Schedules a task for asynchronous execution. The task will be executed once only.
|
|
Gets the number of threads in the pool.
|
|
Gets the size controller which manages the number of threads in the pool.
|
|
The current thread of execution is blocked until the timestamp is met or the sum of all active and pending tasks is equal or less than a given threshold.
|
|
The current thread of execution is blocked until the sum of all active and pending tasks is equal or less than a given threshold.
|