22 #ifndef THREADPOOL_POOL_HPP_INCLUDED 23 #define THREADPOOL_POOL_HPP_INCLUDED 25 #include <boost/ref.hpp> 40 namespace boost {
namespace threadpool
68 template <
typename>
class SchedulingPolicy = fifo_scheduler,
69 template <
typename>
class SizePolicy = static_size,
70 template <
typename>
class SizePolicyController = resize_controller,
71 template <
typename>
class ShutdownPolicy = wait_for_all_tasks
100 : m_core(new pool_core_type)
101 , m_shutdown_controller(static_cast<
void*>(0), bind(&pool_core_type::shutdown, m_core))
103 size_policy_type::init(*m_core, initial_threads);
113 return m_core->size_controller();
122 return m_core->size();
132 return m_core->schedule(task);
141 return m_core->active();
150 return m_core->pending();
168 return m_core->empty();
176 void wait(
size_t task_threshold = 0)
const 178 m_core->wait(task_threshold);
189 bool wait(xtime
const & timestamp,
size_t task_threshold = 0)
const 191 return m_core->wait(timestamp, task_threshold);
232 #endif // THREADPOOL_POOL_HPP_INCLUDED void wait(size_t task_threshold=0) const
The current thread of execution is blocked until the sum of all active and pending tasks is equal or ...
Task task_type
Indicates the task's type.
The namespace threadpool contains a thread pool and related utility classes.
detail::pool_core< Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > pool_core_type
SchedulingPolicy< task_type > scheduler_type
Indicates the scheduler's type.
SizePolicyController< pool_core_type > size_controller_type
SizePolicy< pool_core_type > size_policy_type
class MergingTransformer< Out(const vector_of_const_< In > void
thread_pool< task_func, fifo_scheduler, static_size, resize_controller, wait_for_all_tasks > fifo_pool
Fifo pool.
bool schedule(task_type const &task)
Schedules a task for asynchronous execution.
bool empty() const
Indicates that there are no tasks pending.
thread_pool< task_func, lifo_scheduler, static_size, resize_controller, wait_for_all_tasks > lifo_pool
Lifo pool.
thread_pool(size_t initial_threads=0)
Constructor.
thread_pool< prio_task_func, prio_scheduler, static_size, resize_controller, wait_for_all_tasks > prio_pool
Pool for prioritized task.
shared_ptr< void > m_shutdown_controller
size_t pending() const
Returns the number of tasks which are ready for execution.
fifo_pool pool
A standard pool.
size_t active() const
Returns the number of tasks which are currently executed.
size_controller_type size_controller()
Gets the size controller which manages the number of threads in the pool.
shared_ptr< pool_core_type > m_core
bool wait(xtime const ×tamp, size_t task_threshold=0) const
The current thread of execution is blocked until the timestamp is met or the sum of all active and pe...
void clear()
Removes all pending tasks from the pool's scheduler.
The locking_ptr is smart pointer with a scoped locking mechanism.
function0< void > task_func
Standard task function object.
size_t size() const
Gets the number of threads in the pool.
Task scheduling policies.