Public Types | Public Member Functions | Private Types | Private Attributes
boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > Class Template Reference

Thread pool. More...

#include <pool.hpp>

List of all members.

Public Types

typedef SchedulingPolicy
< task_type
scheduler_type
 Indicates the scheduler's type.
typedef SizePolicyController
< pool_core_type
size_controller_type
typedef SizePolicy
< pool_core_type
size_policy_type
typedef Task task_type
 Indicates the task's 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)
void wait (size_t task_threshold=0) const
bool wait (xtime const &timestamp, size_t task_threshold=0) const

Private Types

typedef detail::pool_core
< Task, SchedulingPolicy,
SizePolicy,
SizePolicyController,
ShutdownPolicy > 
pool_core_type

Private Attributes

shared_ptr< pool_core_typem_core
shared_ptr< void > m_shutdown_controller

Detailed Description

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
class boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >

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.

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.

Parameters:
TaskA function object which implements the operator 'void operator() (void) const'. The operator () is called by the pool to execute the task. Exceptions are ignored.
SchedulingPolicyA 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.
Remarks:
The pool class is thread-safe.
See also:
Tasks: task_func, prio_task_func
Scheduling policies: fifo_scheduler, lifo_scheduler, prio_scheduler

Definition at line 73 of file pool.hpp.


Member Typedef Documentation

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
typedef detail::pool_core<Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::pool_core_type [private]

Definition at line 79 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
typedef SchedulingPolicy<task_type> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::scheduler_type

Indicates the scheduler's type.

Definition at line 85 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
typedef SizePolicyController<pool_core_type> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size_controller_type

Definition at line 92 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
typedef SizePolicy<pool_core_type> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size_policy_type

Definition at line 91 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
typedef Task boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::task_type

Indicates the task's type.

Definition at line 84 of file pool.hpp.


Constructor & Destructor Documentation

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::thread_pool ( size_t  initial_threads = 0) [inline]

Constructor.

Parameters:
initial_threadsThe pool is immediately resized to set the specified number of threads. The pool's actual number threads depends on the SizePolicy.

Definition at line 99 of file pool.hpp.


Member Function Documentation

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
size_t boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::active ( ) const [inline]

Returns the number of tasks which are currently executed.

Returns:
The number of active tasks.

Definition at line 139 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
void boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::clear ( ) [inline]

Removes all pending tasks from the pool's scheduler.

Definition at line 156 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
bool boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::empty ( ) const [inline]

Indicates that there are no tasks pending.

Returns:
true if there are no tasks ready for execution.
Remarks:
This function is more efficient that the check 'pending() == 0'.

Definition at line 166 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
size_t boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::pending ( ) const [inline]

Returns the number of tasks which are ready for execution.

Returns:
The number of pending tasks.

Definition at line 148 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
bool boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::schedule ( task_type const &  task) [inline]

Schedules a task for asynchronous execution. The task will be executed once only.

Parameters:
taskThe task function object. It should not throw execeptions.
Returns:
true, if the task could be scheduled and false otherwise.

Definition at line 130 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
size_t boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size ( ) const [inline]

Gets the number of threads in the pool.

Returns:
The number of threads.

Definition at line 120 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
size_controller_type boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size_controller ( ) [inline]

Gets the size controller which manages the number of threads in the pool.

Returns:
The size controller.
See also:
SizePolicy

Definition at line 111 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
void boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::wait ( size_t  task_threshold = 0) const [inline]

The current thread of execution is blocked until the sum of all active and pending tasks is equal or less than a given threshold.

Parameters:
task_thresholdThe maximum number of tasks in pool and scheduler.

Definition at line 176 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
bool boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::wait ( xtime const &  timestamp,
size_t  task_threshold = 0 
) const [inline]

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.

Parameters:
timestampThe time when function returns at the latest.
task_thresholdThe maximum number of tasks in pool and scheduler.
Returns:
true if the task sum is equal or less than the threshold, false otherwise.

Definition at line 189 of file pool.hpp.


Member Data Documentation

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
shared_ptr<pool_core_type> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_core [private]

Definition at line 80 of file pool.hpp.

template<typename Task = task_func, template< typename > class SchedulingPolicy = fifo_scheduler, template< typename > class SizePolicy = static_size, template< typename > class SizePolicyController = resize_controller, template< typename > class ShutdownPolicy = wait_for_all_tasks>
shared_ptr<void> boost::threadpool::thread_pool< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_shutdown_controller [private]

Definition at line 81 of file pool.hpp.


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


or_libs
Author(s): raphael
autogenerated on Mon Oct 6 2014 02:53:19