Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > Class Template Reference

Thread pool. More...

#include <pool_core.hpp>

Inheritance diagram for boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >:
Inheritance graph
[legend]

Public Types

typedef pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > pool_type
 Indicates the thread pool's type. More...
 
typedef SchedulingPolicy< task_typescheduler_type
 Indicates the scheduler's type. More...
 
typedef ShutdownPolicy< pool_typeshutdown_policy_type
 Indicates the shutdown policy's type. More...
 
typedef SizePolicyController< pool_typesize_controller_type
 
typedef SizePolicy< pool_typesize_policy_type
 Indicates the sizer's type. More...
 
typedef Task task_type
 Indicates the task's type. More...
 
typedef worker_thread< pool_typeworker_type
 

Public Member Functions

size_t active () const volatile
 
 BOOST_STATIC_ASSERT (function_traits< task_type()>::arity==0)
 
 BOOST_STATIC_ASSERT (is_void< typename result_of< task_type()>::type >::value)
 
void clear () volatile
 
bool empty () const volatile
 
size_t pending () const volatile
 
 pool_core ()
 Constructor. More...
 
bool schedule (task_type const &task) volatile
 
void shutdown ()
 
size_t size () const volatile
 
size_controller_type size_controller ()
 
void wait (size_t const task_threshold=0) const volatile
 
bool wait (xtime const &timestamp, size_t const task_threshold=0) const volatile
 
 ~pool_core ()
 Destructor. More...
 

Private Member Functions

bool execute_task () volatile
 
bool resize (size_t const worker_count) volatile
 
void terminate_all_workers (bool const wait) volatile
 
void worker_destructed (shared_ptr< worker_type > worker) volatile
 
void worker_died_unexpectedly (shared_ptr< worker_type > worker) volatile
 

Private Attributes

volatile size_t m_active_worker_count
 
recursive_mutex m_monitor
 
scheduler_type m_scheduler
 
scoped_ptr< size_policy_typem_size_policy
 
volatile size_t m_target_worker_count
 
condition m_task_or_terminate_workers_event
 
bool m_terminate_all_workers
 
std::vector< shared_ptr< worker_type > > m_terminated_workers
 
volatile size_t m_worker_count
 
condition m_worker_idle_or_terminated_event
 

Friends

class ShutdownPolicy< pool_type >
 
class SizePolicy< pool_type >
 
class worker_thread< pool_type >
 

Detailed Description

template<typename Task, template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
class boost::threadpool::detail::pool_core< 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_impl is DefaultConstructible and NonCopyable.

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.
SchedulerA 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 75 of file pool_core.hpp.

Member Typedef Documentation

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef pool_core<Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::pool_type

Indicates the thread pool's type.

Definition at line 87 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef SchedulingPolicy<task_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::scheduler_type

Indicates the scheduler's type.

Definition at line 82 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef ShutdownPolicy<pool_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::shutdown_policy_type

Indicates the shutdown policy's type.

Definition at line 94 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef SizePolicyController<pool_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size_controller_type

Definition at line 91 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef SizePolicy<pool_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size_policy_type

Indicates the sizer's type.

Definition at line 88 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef Task boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::task_type

Indicates the task's type.

Definition at line 81 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
typedef worker_thread<pool_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::worker_type

Definition at line 96 of file pool_core.hpp.

Constructor & Destructor Documentation

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::pool_core ( )
inline

Constructor.

Definition at line 137 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::~pool_core ( )
inline

Destructor.

Definition at line 151 of file pool_core.hpp.

Member Function Documentation

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::active ( ) const volatile
inline

Returns the number of tasks which are currently executed.

Returns
The number of active tasks.

Definition at line 201 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::BOOST_STATIC_ASSERT ( function_traits< task_type()>::arity  = =0)
template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::BOOST_STATIC_ASSERT ( is_void< typename result_of< task_type()>::type >::value  )
template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::clear ( ) volatile
inline

Removes all pending tasks from the pool's scheduler.

Definition at line 219 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::empty ( ) const volatile
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 230 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::execute_task ( ) volatile
inlineprivate

Definition at line 401 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::pending ( ) const volatile
inline

Returns the number of tasks which are ready for execution.

Returns
The number of pending tasks.

Definition at line 210 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::resize ( size_t const  worker_count) volatile
inlineprivate

Changes the number of worker threads in the pool. The resizing is handled by the SizePolicy.

Parameters
threadsThe new number of worker threads.
Returns
true, if pool will be resized and false if not.

Definition at line 329 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::schedule ( task_type const &  task) volatile
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 182 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::shutdown ( )
inline

Definition at line 173 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::size ( ) const volatile
inline

Gets the number of threads in the pool.

Returns
The number of threads.

Definition at line 167 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
size_controller_type boost::threadpool::detail::pool_core< 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 159 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::terminate_all_workers ( bool const  wait) volatile
inlineprivate

Definition at line 296 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::wait ( size_t const  task_threshold = 0) const volatile
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 241 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::wait ( xtime const &  timestamp,
size_t const  task_threshold = 0 
) const volatile
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 269 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::worker_destructed ( shared_ptr< worker_type worker) volatile
inlineprivate

Definition at line 387 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
void boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::worker_died_unexpectedly ( shared_ptr< worker_type worker) volatile
inlineprivate

Definition at line 369 of file pool_core.hpp.

Friends And Related Function Documentation

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
friend class ShutdownPolicy< pool_type >
friend

Definition at line 113 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
friend class SizePolicy< pool_type >
friend

Definition at line 112 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
friend class worker_thread< pool_type >
friend

Definition at line 106 of file pool_core.hpp.

Member Data Documentation

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
volatile size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_active_worker_count
private

Definition at line 119 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
recursive_mutex boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_monitor
mutableprivate

Definition at line 131 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
scheduler_type boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_scheduler
private

Definition at line 124 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
scoped_ptr<size_policy_type> boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_size_policy
private

Definition at line 125 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
volatile size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_target_worker_count
private

Definition at line 118 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
condition boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_task_or_terminate_workers_event
mutableprivate

Definition at line 133 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
bool boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_terminate_all_workers
private

Definition at line 127 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
std::vector<shared_ptr<worker_type> > boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_terminated_workers
private

Definition at line 128 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
volatile size_t boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_worker_count
private

Definition at line 117 of file pool_core.hpp.

template<typename Task , template< typename > class SchedulingPolicy, template< typename > class SizePolicy, template< typename > class SizePolicyController, template< typename > class ShutdownPolicy>
condition boost::threadpool::detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy >::m_worker_idle_or_terminated_event
mutableprivate

Definition at line 132 of file pool_core.hpp.


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


asr_descriptor_surface_based_recognition
Author(s): Allgeyer Tobias, Hutmacher Robin, Meißner Pascal
autogenerated on Mon Dec 16 2019 03:31:16