Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::executors::basic_thread_pool Class Reference

#include <basic_thread_pool.hpp>

Public Types

typedef executors::work work
 type-erasure to store the works to do More...
 

Public Member Functions

bool try_executing_one ()
 Effects: try to execute one task. More...
 
void schedule_one_or_yield ()
 Effects: schedule one task or yields Throws: whatever the current task constructor throws or the task() throws. More...
 
 basic_thread_pool (unsigned const thread_count=thread::hardware_concurrency())
 basic_thread_pool is not copyable. More...
 
 basic_thread_pool (unsigned const thread_count, void(*at_thread_entry)(basic_thread_pool &))
 Effects: creates a thread pool that runs closures on thread_count threads and executes the at_thread_entry function at the entry of each created thread. More...
 
template<class AtThreadEntry >
 basic_thread_pool (unsigned const thread_count, BOOST_THREAD_FWD_REF(AtThreadEntry) at_thread_entry)
 
 ~basic_thread_pool ()
 Effects: Destroys the thread pool. More...
 
void join ()
 Effects: join all the threads. More...
 
void close ()
 Effects: close the basic_thread_pool for submissions. More...
 
bool closed ()
 Returns: whether the pool is closed for submissions. More...
 
void submit (void(*closure)())
 Requires: Closure is a model of Callable(void()) and a model of CopyConstructible/MoveConstructible. More...
 
template<typename Closure >
void submit (BOOST_THREAD_RV_REF(Closure) closure)
 
template<typename Pred >
bool reschedule_until (Pred const &pred)
 Requires: This must be called from an scheduled task. More...
 

Member Typedef Documentation

type-erasure to store the works to do

Constructor & Destructor Documentation

boost::executors::basic_thread_pool::basic_thread_pool ( unsigned const  thread_count = thread::hardware_concurrency())
inline

basic_thread_pool is not copyable.

Effects: creates a thread pool that runs closures on thread_count threads.

Throws: Whatever exception is thrown while initializing the needed resources.

References close(), boost::multiprecision::backends::i, and boost::move().

boost::executors::basic_thread_pool::basic_thread_pool ( unsigned const  thread_count,
void(*)(basic_thread_pool &)  at_thread_entry 
)
inline

Effects: creates a thread pool that runs closures on thread_count threads and executes the at_thread_entry function at the entry of each created thread.

Throws: Whatever exception is thrown while initializing the needed resources.

References close(), boost::multiprecision::backends::i, and boost::move().

template<class AtThreadEntry >
boost::executors::basic_thread_pool::basic_thread_pool ( unsigned const  thread_count,
BOOST_THREAD_FWD_REF(AtThreadEntry)  at_thread_entry 
)
inline
boost::executors::basic_thread_pool::~basic_thread_pool ( )
inline

Effects: Destroys the thread pool.

Synchronization: The completion of all the closures happen before the completion of the basic_thread_pool destructor.

References close().

Member Function Documentation

void boost::executors::basic_thread_pool::close ( )
inline

Effects: close the basic_thread_pool for submissions.

The worker threads will work until there is no more closures to run.

References boost::sync_queue< ValueType >::close().

Referenced by basic_thread_pool(), and ~basic_thread_pool().

bool boost::executors::basic_thread_pool::closed ( )
inline

Returns: whether the pool is closed for submissions.

References boost::sync_queue< ValueType >::closed().

void boost::executors::basic_thread_pool::join ( )
inline

Effects: join all the threads.

References boost::multiprecision::backends::i.

template<typename Pred >
bool boost::executors::basic_thread_pool::reschedule_until ( Pred const &  pred)
inline

Requires: This must be called from an scheduled task.

Effects: reschedule functions until pred()

References try_executing_one().

void boost::executors::basic_thread_pool::schedule_one_or_yield ( )
inline

Effects: schedule one task or yields Throws: whatever the current task constructor throws or the task() throws.

References try_executing_one(), and boost::this_thread::yield().

void boost::executors::basic_thread_pool::submit ( void(*)()  closure)
inline

Requires: Closure is a model of Callable(void()) and a model of CopyConstructible/MoveConstructible.

Effects: The specified closure will be scheduled for execution at some point in the future. If invoked closure throws an exception the basic_thread_pool will call std::terminate, as is the case with threads.

Synchronization: completion of closure on a particular thread happens before destruction of thread's thread local variables.

Throws: sync_queue_is_closed if the thread pool is closed. Whatever exception that can be throw while storing the closure.

References boost::sync_queue< ValueType >::push_back().

template<typename Closure >
void boost::executors::basic_thread_pool::submit ( BOOST_THREAD_RV_REF(Closure)  closure)
inline
bool boost::executors::basic_thread_pool::try_executing_one ( )
inline

Effects: try to execute one task.

Returns: whether a task has been executed. Throws: whatever the current task constructor throws or the task() throws.

References boost::exception, boost::sinks::event_log::success, and boost::sync_queue< ValueType >::try_pull_front().

Referenced by reschedule_until(), and schedule_one_or_yield().


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