Kagome
Polkadot Runtime Engine in C++17
basic_waitable_timer.cpp
Go to the documentation of this file.
1 
7 
8 namespace kagome::clock {
10  std::shared_ptr<boost::asio::io_context> io_context)
11  : io_context_([&] {
12  BOOST_ASSERT(io_context);
13  return std::move(io_context);
14  }()),
15  timer_{boost::asio::basic_waitable_timer<std::chrono::system_clock>{
16  *io_context_}} {}
17 
19  timer_.expires_at(at);
20  }
21 
23  timer_.expires_after(duration);
24  }
25 
27  timer_.cancel();
28  }
29 
31  const std::function<void(const std::error_code &)> &h) {
32  timer_.async_wait(h);
33  }
34 } // namespace kagome::clock
boost::asio::basic_waitable_timer< std::chrono::system_clock > timer_
std::shared_ptr< boost::asio::io_context > io_context_
void expiresAt(clock::SystemClock::TimePoint at) override
void asyncWait(const std::function< void(const std::error_code &)> &h) override
void expiresAfter(clock::SystemClock::Duration duration) override
typename ClockType::duration Duration
Definition: clock.hpp:23
BasicWaitableTimer(std::shared_ptr< boost::asio::io_context > io_context)
typename ClockType::time_point TimePoint
Definition: clock.hpp:27