Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:39:20

0001 //
0002 // Copyright (c) 2025 Klemens Morgenstern (klemens.morgenstern@gmx.net)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_COBALT_IO_STEADY_TIMER_HPP
0009 #define BOOST_COBALT_IO_STEADY_TIMER_HPP
0010 
0011 #include <boost/cobalt/io/detail/config.hpp>
0012 #include <boost/cobalt/op.hpp>
0013 #include <boost/cobalt/io/ops.hpp>
0014 #include <boost/asio/basic_waitable_timer.hpp>
0015 
0016 #include <boost/system/result.hpp>
0017 
0018 namespace boost::cobalt::io
0019 {
0020 
0021 struct BOOST_SYMBOL_VISIBLE steady_timer
0022 {
0023   /// The clock type.
0024   typedef std::chrono::steady_clock clock_type;
0025 
0026   /// The duration type of the clock.
0027   typedef typename clock_type::duration duration;
0028 
0029   /// The time point type of the clock.
0030   typedef typename clock_type::time_point time_point;
0031 
0032   BOOST_COBALT_IO_DECL steady_timer(const cobalt::executor & executor = this_thread::get_executor());
0033   BOOST_COBALT_IO_DECL steady_timer(const time_point& expiry_time, const cobalt::executor & executor = this_thread::get_executor());
0034   BOOST_COBALT_IO_DECL steady_timer(const duration& expiry_time,   const cobalt::executor & executor = this_thread::get_executor());
0035 
0036   void cancel();
0037 
0038   BOOST_COBALT_IO_DECL time_point expiry() const;
0039   BOOST_COBALT_IO_DECL void reset(const time_point& expiry_time);
0040   BOOST_COBALT_IO_DECL void reset(const duration& expiry_time);
0041   BOOST_COBALT_IO_DECL bool expired() const;
0042   [[nodiscard]] wait_op wait() { return {this, initiate_wait_, try_wait_}; }
0043  private:
0044 
0045   BOOST_COBALT_IO_DECL static void initiate_wait_(void *, boost::cobalt::completion_handler<system::error_code>);
0046   BOOST_COBALT_IO_DECL static void try_wait_(void *, boost::cobalt::handler<system::error_code>);
0047   asio::basic_waitable_timer<std::chrono::steady_clock,
0048                              asio::wait_traits<std::chrono::steady_clock>,
0049                              executor> timer_;
0050 };
0051 
0052 }
0053 
0054 #endif //BOOST_COBALT_IO_STEADY_TIMER_HPP