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

#include <serial_executor.hpp>

Public Types

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

Public Member Functions

generic_executor_ref underlying_executor () BOOST_NOEXCEPT
 
bool try_executing_one ()
 Effects: try to execute one task. More...
 
template<class Executor >
 serial_executor (Executor &ex)
 serial_executor is not copyable. More...
 
 ~serial_executor ()
 Effects: Destroys the thread pool. More...
 
void close ()
 Effects: close the serial_executor 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

template<class Executor >
boost::executors::serial_executor::serial_executor ( Executor &  ex)
inline

serial_executor is not copyable.

Effects: creates a thread pool that runs closures using one of its closure-executing methods.

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

boost::executors::serial_executor::~serial_executor ( )
inline

Effects: Destroys the thread pool.

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

References close().

Member Function Documentation

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

Effects: close the serial_executor for submissions.

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

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

Referenced by ~serial_executor().

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

Returns: whether the pool is closed for submissions.

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

template<typename Pred >
bool boost::executors::serial_executor::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::serial_executor::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 serial_executor 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::serial_executor::submit ( BOOST_THREAD_RV_REF(Closure)  closure)
inline
bool boost::executors::serial_executor::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::promise< void >::get_future(), boost::multiprecision::backends::p, boost::executors::generic_executor_ref::submit(), boost::sinks::event_log::success, and boost::sync_queue< ValueType >::try_pull_front().

Referenced by reschedule_until().

generic_executor_ref boost::executors::serial_executor::underlying_executor ( )
inline
Returns
The underlying executor wrapped on a generic executor reference.

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