A class for scheduling functions to be called after a specific amount of ticks. A tick is equal to 1 second. More...
Public Types | |
using | task_type = std::function< void()> |
using | identifier_type = size_t |
Public Member Functions | |
task_timer (boost::asio::io_service &io_service) | |
~task_timer () | |
void | cancel (identifier_type id) |
identifier_type | schedule (const task_type &task) |
Schedule the given task to be executed after the default amount of ticks. More... | |
identifier_type | schedule (const task_type &task, std::uint8_t timeout) |
Schedule the given task to be executed after the given time. More... | |
void | set_default_timeout (std::uint8_t timeout) |
Set the default timeout for this task_timer instance. (Default: 5) More... | |
std::uint8_t | get_default_timeout () const |
Get the default timeout. (Default: 5) More... | |
Private Types | |
using | clock_type = std::chrono::steady_clock |
using | time_type = clock_type::time_point |
Private Member Functions | |
void | process_tasks () |
void | tick_handler (const boost::system::error_code &ec) |
Private Attributes | |
std::uint8_t | default_timeout_ {5} |
boost::asio::io_service & | io_service_ |
boost::asio::deadline_timer | deadline_timer_ |
std::map< identifier_type, std::pair< time_type, task_type > > | tasks_ |
identifier_type | highest_id_ {0} |
A class for scheduling functions to be called after a specific amount of ticks. A tick is equal to 1 second.
using crow::detail::task_timer::task_type = std::function<void()> |
using crow::detail::task_timer::identifier_type = size_t |
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
Schedule the given task to be executed after the default amount of ticks.
|
inline |
Schedule the given task to be executed after the given time.
task | . |
timeout | The amount of ticks (seconds) to wait before execution. |
|
inline |
Set the default timeout for this task_timer instance. (Default: 5)
timeout | The amount of ticks (seconds) to wait before execution. |
|
inline |
Get the default timeout. (Default: 5)
|
inlineprivate |
|
inlineprivate |
|
private |
|
private |
|
private |
|
private |
|
private |