Scheduler, combines Boost.ASIO with a managed thread pool for scheduling server threads.
More...
#include <staticlib/pion/scheduler.hpp>
Public Member Functions |
| | scheduler (uint32_t number_of_threads) |
| | Constructor.
|
| scheduler & | operator= (const scheduler &) |
| | Deleted copy assignment operator.
|
| | ~scheduler () |
| | Destructor.
|
| void | startup () |
| | Starts the thread scheduler (this is called automatically when necessary)
|
| void | shutdown () |
| | Stops the thread scheduler (this is called automatically when the program exits)
|
| void | join () |
| | The calling thread will sleep until the scheduler has stopped.
|
| void | add_active_user () |
| | Registers an active user with the thread scheduler.
|
| void | remove_active_user () |
| | Unregisters an active user with the thread scheduler.
|
| bool | is_running () const |
| | Returns true if the scheduler is running.
|
| asio::io_service & | get_io_service () |
| | Returns an async I/O service used to schedule work.
|
| void | post (std::function< void()> work_func) |
| | Schedules work to be performed by one of the pooled threads.
|
| void | keep_running (asio::io_service &my_service, asio::steady_timer &my_timer) |
| | Thread function used to keep the io_service running.
|
| void | process_service_work (asio::io_service &service) |
| | processes work passed to the asio service & handles uncaught exceptions
|
| void | set_thread_stop_hook (std::function< void() > hook) |
| | Setter for hook function, that is called from each worker thread just before that worker thread is going to exit.
|
Detailed Description
Scheduler, combines Boost.ASIO with a managed thread pool for scheduling server threads.
Constructor & Destructor Documentation
| staticlib::pion::scheduler::scheduler |
( |
uint32_t |
number_of_threads | ) |
|
|
inline |
| staticlib::pion::scheduler::~scheduler |
( |
| ) |
|
|
inline |
Member Function Documentation
| void staticlib::pion::scheduler::add_active_user |
( |
| ) |
|
Registers an active user with the thread scheduler.
Shutdown of the scheduler is deferred until there are no more active users. This ensures that any work queued will not reference destructed objects
| asio::io_service& staticlib::pion::scheduler::get_io_service |
( |
| ) |
|
|
inline |
Returns an async I/O service used to schedule work.
- Returns
- asio service
| bool staticlib::pion::scheduler::is_running |
( |
| ) |
const |
|
inline |
Returns true if the scheduler is running.
- Returns
- whether scheduler is running
| void staticlib::pion::scheduler::join |
( |
| ) |
|
The calling thread will sleep until the scheduler has stopped.
| void staticlib::pion::scheduler::keep_running |
( |
asio::io_service & |
my_service, |
|
|
asio::steady_timer & |
my_timer |
|
) |
| |
Thread function used to keep the io_service running.
- Parameters
-
| my_service | IO service used to re-schedule keep_running() |
| my_timer | deadline timer used to keep the IO service active while running |
Deleted copy assignment operator.
| void staticlib::pion::scheduler::post |
( |
std::function< void()> |
work_func | ) |
|
|
inline |
Schedules work to be performed by one of the pooled threads.
- Parameters
-
| work_func | work function to be executed |
| void staticlib::pion::scheduler::process_service_work |
( |
asio::io_service & |
service | ) |
|
processes work passed to the asio service & handles uncaught exceptions
- Parameters
-
| void staticlib::pion::scheduler::remove_active_user |
( |
| ) |
|
Unregisters an active user with the thread scheduler.
| void staticlib::pion::scheduler::set_thread_stop_hook |
( |
std::function< void() > |
hook | ) |
|
|
inline |
Setter for hook function, that is called from each worker thread just before that worker thread is going to exit.
- Parameters
-
| void staticlib::pion::scheduler::shutdown |
( |
| ) |
|
Stops the thread scheduler (this is called automatically when the program exits)
| void staticlib::pion::scheduler::startup |
( |
| ) |
|
Starts the thread scheduler (this is called automatically when necessary)
The documentation for this class was generated from the following file: