26#include <asio/error_code.hpp>
27#include <asio/steady_timer.hpp>
46 :
timer_(executor->context(type)) {}
55 template <
typename Function>
57 std::chrono::steady_clock::time_point time, Function&& function) {
59 timer_.async_wait([function_moved = std::forward<Function>(function)](
60 const asio::error_code& error)
mutable {
74 template <
typename Function>
76 std::chrono::steady_clock::duration duration, Function&& function) {
77 timer_.expires_after(duration);
78 timer_.async_wait([function_moved = std::forward<Function>(function)](
79 const asio::error_code& error)
mutable {
void cancel()
Cancel this timer.
asio::steady_timer timer_
Timer in asio library.
Timer(const std::shared_ptr< IExecutor > &executor, OperationType type)
Constructor.
void async_sleep_for(std::chrono::steady_clock::duration duration, Function &&function)
Asynchronously sleep for a duration.
void async_sleep_until(std::chrono::steady_clock::time_point time, Function &&function)
Asynchronously sleep until a time point.
Definition of IExecutor class.
Namespace of executors to process asynchronous tasks.
OperationType
Enumeration of types of operations.
Definition of OperationType enumeration.