Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Timer.hpp
1#pragma once
2
3#include <boost/asio/steady_timer.hpp>
4
5namespace util::async::impl {
6
7template <typename ExecutorType>
8class SteadyTimer {
9 boost::asio::steady_timer timer_;
10
11public:
12 SteadyTimer(ExecutorType& executor, auto delay, auto&& fn) : timer_{executor}
13 {
14 timer_.expires_after(delay);
15 timer_.async_wait(std::forward<decltype(fn)>(fn));
16 }
17
18 SteadyTimer(SteadyTimer&&) = default;
19
20 SteadyTimer(SteadyTimer const&) = delete;
21
22 void
23 cancel() noexcept
24 {
25 timer_.cancel();
26 }
27};
28
29} // namespace util::async::impl