Kagome
Polkadot Runtime Engine in C++17
basic_waitable_timer.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_BASIC_WAITABLE_TIMER_HPP
7 #define KAGOME_BASIC_WAITABLE_TIMER_HPP
8 
9 #include <boost/asio/basic_waitable_timer.hpp>
10 #include <boost/asio/io_context.hpp>
11 #include "clock/timer.hpp"
12 
13 namespace kagome::clock {
17  class BasicWaitableTimer : public Timer {
18  public:
19  explicit BasicWaitableTimer(
20  std::shared_ptr<boost::asio::io_context> io_context);
21 
22  ~BasicWaitableTimer() override = default;
23 
24  void expiresAt(clock::SystemClock::TimePoint at) override;
25 
26  void expiresAfter(clock::SystemClock::Duration duration) override;
27 
28  void cancel() override;
29 
30  void asyncWait(
31  const std::function<void(const std::error_code &)> &h) override;
32 
33  private:
34  std::shared_ptr<boost::asio::io_context> io_context_;
35  boost::asio::basic_waitable_timer<std::chrono::system_clock> timer_;
36  };
37 } // namespace kagome::clock
38 
39 #endif // KAGOME_BASIC_WAITABLE_TIMER_HPP
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
~BasicWaitableTimer() override=default
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