Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:04

0001 //
0002 // basic_deadline_timer.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
0012 #define BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 
0020 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
0021   || defined(GENERATING_DOCUMENTATION)
0022 
0023 #include <cstddef>
0024 #include <boost/asio/any_io_executor.hpp>
0025 #include <boost/asio/detail/deadline_timer_service.hpp>
0026 #include <boost/asio/detail/handler_type_requirements.hpp>
0027 #include <boost/asio/detail/io_object_impl.hpp>
0028 #include <boost/asio/detail/non_const_lvalue.hpp>
0029 #include <boost/asio/detail/throw_error.hpp>
0030 #include <boost/asio/error.hpp>
0031 #include <boost/asio/execution_context.hpp>
0032 #include <boost/asio/time_traits.hpp>
0033 
0034 #include <boost/asio/detail/push_options.hpp>
0035 
0036 namespace boost {
0037 namespace asio {
0038 
0039 /// Provides waitable timer functionality.
0040 /**
0041  * The basic_deadline_timer class template provides the ability to perform a
0042  * blocking or asynchronous wait for a timer to expire.
0043  *
0044  * A deadline timer is always in one of two states: "expired" or "not expired".
0045  * If the wait() or async_wait() function is called on an expired timer, the
0046  * wait operation will complete immediately.
0047  *
0048  * Most applications will use the boost::asio::deadline_timer typedef.
0049  *
0050  * @par Thread Safety
0051  * @e Distinct @e objects: Safe.@n
0052  * @e Shared @e objects: Unsafe.
0053  *
0054  * @par Examples
0055  * Performing a blocking wait:
0056  * @code
0057  * // Construct a timer without setting an expiry time.
0058  * boost::asio::deadline_timer timer(my_context);
0059  *
0060  * // Set an expiry time relative to now.
0061  * timer.expires_from_now(boost::posix_time::seconds(5));
0062  *
0063  * // Wait for the timer to expire.
0064  * timer.wait();
0065  * @endcode
0066  *
0067  * @par 
0068  * Performing an asynchronous wait:
0069  * @code
0070  * void handler(const boost::system::error_code& error)
0071  * {
0072  *   if (!error)
0073  *   {
0074  *     // Timer expired.
0075  *   }
0076  * }
0077  *
0078  * ...
0079  *
0080  * // Construct a timer with an absolute expiry time.
0081  * boost::asio::deadline_timer timer(my_context,
0082  *     boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
0083  *
0084  * // Start an asynchronous wait.
0085  * timer.async_wait(handler);
0086  * @endcode
0087  *
0088  * @par Changing an active deadline_timer's expiry time
0089  *
0090  * Changing the expiry time of a timer while there are pending asynchronous
0091  * waits causes those wait operations to be cancelled. To ensure that the action
0092  * associated with the timer is performed only once, use something like this:
0093  * used:
0094  *
0095  * @code
0096  * void on_some_event()
0097  * {
0098  *   if (my_timer.expires_from_now(seconds(5)) > 0)
0099  *   {
0100  *     // We managed to cancel the timer. Start new asynchronous wait.
0101  *     my_timer.async_wait(on_timeout);
0102  *   }
0103  *   else
0104  *   {
0105  *     // Too late, timer has already expired!
0106  *   }
0107  * }
0108  *
0109  * void on_timeout(const boost::system::error_code& e)
0110  * {
0111  *   if (e != boost::asio::error::operation_aborted)
0112  *   {
0113  *     // Timer was not cancelled, take necessary action.
0114  *   }
0115  * }
0116  * @endcode
0117  *
0118  * @li The boost::asio::basic_deadline_timer::expires_from_now() function
0119  * cancels any pending asynchronous waits, and returns the number of
0120  * asynchronous waits that were cancelled. If it returns 0 then you were too
0121  * late and the wait handler has already been executed, or will soon be
0122  * executed. If it returns 1 then the wait handler was successfully cancelled.
0123  *
0124  * @li If a wait handler is cancelled, the boost::system::error_code passed to
0125  * it contains the value boost::asio::error::operation_aborted.
0126  */
0127 template <typename Time,
0128     typename TimeTraits = boost::asio::time_traits<Time>,
0129     typename Executor = any_io_executor>
0130 class basic_deadline_timer
0131 {
0132 private:
0133   class initiate_async_wait;
0134 
0135 public:
0136   /// The type of the executor associated with the object.
0137   typedef Executor executor_type;
0138 
0139   /// Rebinds the timer type to another executor.
0140   template <typename Executor1>
0141   struct rebind_executor
0142   {
0143     /// The timer type when rebound to the specified executor.
0144     typedef basic_deadline_timer<Time, TimeTraits, Executor1> other;
0145   };
0146 
0147   /// The time traits type.
0148   typedef TimeTraits traits_type;
0149 
0150   /// The time type.
0151   typedef typename traits_type::time_type time_type;
0152 
0153   /// The duration type.
0154   typedef typename traits_type::duration_type duration_type;
0155 
0156   /// Constructor.
0157   /**
0158    * This constructor creates a timer without setting an expiry time. The
0159    * expires_at() or expires_from_now() functions must be called to set an
0160    * expiry time before the timer can be waited on.
0161    *
0162    * @param ex The I/O executor that the timer will use, by default, to
0163    * dispatch handlers for any asynchronous operations performed on the timer.
0164    */
0165   explicit basic_deadline_timer(const executor_type& ex)
0166     : impl_(0, ex)
0167   {
0168   }
0169 
0170   /// Constructor.
0171   /**
0172    * This constructor creates a timer without setting an expiry time. The
0173    * expires_at() or expires_from_now() functions must be called to set an
0174    * expiry time before the timer can be waited on.
0175    *
0176    * @param context An execution context which provides the I/O executor that
0177    * the timer will use, by default, to dispatch handlers for any asynchronous
0178    * operations performed on the timer.
0179    */
0180   template <typename ExecutionContext>
0181   explicit basic_deadline_timer(ExecutionContext& context,
0182       constraint_t<
0183         is_convertible<ExecutionContext&, execution_context&>::value
0184       > = 0)
0185     : impl_(0, 0, context)
0186   {
0187   }
0188 
0189   /// Constructor to set a particular expiry time as an absolute time.
0190   /**
0191    * This constructor creates a timer and sets the expiry time.
0192    *
0193    * @param ex The I/O executor that the timer will use, by default, to
0194    * dispatch handlers for any asynchronous operations performed on the timer.
0195    *
0196    * @param expiry_time The expiry time to be used for the timer, expressed
0197    * as an absolute time.
0198    */
0199   basic_deadline_timer(const executor_type& ex, const time_type& expiry_time)
0200     : impl_(0, ex)
0201   {
0202     boost::system::error_code ec;
0203     impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
0204     boost::asio::detail::throw_error(ec, "expires_at");
0205   }
0206 
0207   /// Constructor to set a particular expiry time as an absolute time.
0208   /**
0209    * This constructor creates a timer and sets the expiry time.
0210    *
0211    * @param context An execution context which provides the I/O executor that
0212    * the timer will use, by default, to dispatch handlers for any asynchronous
0213    * operations performed on the timer.
0214    *
0215    * @param expiry_time The expiry time to be used for the timer, expressed
0216    * as an absolute time.
0217    */
0218   template <typename ExecutionContext>
0219   basic_deadline_timer(ExecutionContext& context, const time_type& expiry_time,
0220       constraint_t<
0221         is_convertible<ExecutionContext&, execution_context&>::value
0222       > = 0)
0223     : impl_(0, 0, context)
0224   {
0225     boost::system::error_code ec;
0226     impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
0227     boost::asio::detail::throw_error(ec, "expires_at");
0228   }
0229 
0230   /// Constructor to set a particular expiry time relative to now.
0231   /**
0232    * This constructor creates a timer and sets the expiry time.
0233    *
0234    * @param ex The I/O executor that the timer will use, by default, to
0235    * dispatch handlers for any asynchronous operations performed on the timer.
0236    *
0237    * @param expiry_time The expiry time to be used for the timer, relative to
0238    * now.
0239    */
0240   basic_deadline_timer(const executor_type& ex,
0241       const duration_type& expiry_time)
0242     : impl_(0, ex)
0243   {
0244     boost::system::error_code ec;
0245     impl_.get_service().expires_from_now(
0246         impl_.get_implementation(), expiry_time, ec);
0247     boost::asio::detail::throw_error(ec, "expires_from_now");
0248   }
0249 
0250   /// Constructor to set a particular expiry time relative to now.
0251   /**
0252    * This constructor creates a timer and sets the expiry time.
0253    *
0254    * @param context An execution context which provides the I/O executor that
0255    * the timer will use, by default, to dispatch handlers for any asynchronous
0256    * operations performed on the timer.
0257    *
0258    * @param expiry_time The expiry time to be used for the timer, relative to
0259    * now.
0260    */
0261   template <typename ExecutionContext>
0262   basic_deadline_timer(ExecutionContext& context,
0263       const duration_type& expiry_time,
0264       constraint_t<
0265         is_convertible<ExecutionContext&, execution_context&>::value
0266       > = 0)
0267     : impl_(0, 0, context)
0268   {
0269     boost::system::error_code ec;
0270     impl_.get_service().expires_from_now(
0271         impl_.get_implementation(), expiry_time, ec);
0272     boost::asio::detail::throw_error(ec, "expires_from_now");
0273   }
0274 
0275   /// Move-construct a basic_deadline_timer from another.
0276   /**
0277    * This constructor moves a timer from one object to another.
0278    *
0279    * @param other The other basic_deadline_timer object from which the move will
0280    * occur.
0281    *
0282    * @note Following the move, the moved-from object is in the same state as if
0283    * constructed using the @c basic_deadline_timer(const executor_type&)
0284    * constructor.
0285    */
0286   basic_deadline_timer(basic_deadline_timer&& other)
0287     : impl_(std::move(other.impl_))
0288   {
0289   }
0290 
0291   /// Move-assign a basic_deadline_timer from another.
0292   /**
0293    * This assignment operator moves a timer from one object to another. Cancels
0294    * any outstanding asynchronous operations associated with the target object.
0295    *
0296    * @param other The other basic_deadline_timer object from which the move will
0297    * occur.
0298    *
0299    * @note Following the move, the moved-from object is in the same state as if
0300    * constructed using the @c basic_deadline_timer(const executor_type&)
0301    * constructor.
0302    */
0303   basic_deadline_timer& operator=(basic_deadline_timer&& other)
0304   {
0305     impl_ = std::move(other.impl_);
0306     return *this;
0307   }
0308 
0309   /// Destroys the timer.
0310   /**
0311    * This function destroys the timer, cancelling any outstanding asynchronous
0312    * wait operations associated with the timer as if by calling @c cancel.
0313    */
0314   ~basic_deadline_timer()
0315   {
0316   }
0317 
0318   /// Get the executor associated with the object.
0319   const executor_type& get_executor() noexcept
0320   {
0321     return impl_.get_executor();
0322   }
0323 
0324   /// Cancel any asynchronous operations that are waiting on the timer.
0325   /**
0326    * This function forces the completion of any pending asynchronous wait
0327    * operations against the timer. The handler for each cancelled operation will
0328    * be invoked with the boost::asio::error::operation_aborted error code.
0329    *
0330    * Cancelling the timer does not change the expiry time.
0331    *
0332    * @return The number of asynchronous operations that were cancelled.
0333    *
0334    * @throws boost::system::system_error Thrown on failure.
0335    *
0336    * @note If the timer has already expired when cancel() is called, then the
0337    * handlers for asynchronous wait operations will:
0338    *
0339    * @li have already been invoked; or
0340    *
0341    * @li have been queued for invocation in the near future.
0342    *
0343    * These handlers can no longer be cancelled, and therefore are passed an
0344    * error code that indicates the successful completion of the wait operation.
0345    */
0346   std::size_t cancel()
0347   {
0348     boost::system::error_code ec;
0349     std::size_t s = impl_.get_service().cancel(impl_.get_implementation(), ec);
0350     boost::asio::detail::throw_error(ec, "cancel");
0351     return s;
0352   }
0353 
0354   /// Cancel any asynchronous operations that are waiting on the timer.
0355   /**
0356    * This function forces the completion of any pending asynchronous wait
0357    * operations against the timer. The handler for each cancelled operation will
0358    * be invoked with the boost::asio::error::operation_aborted error code.
0359    *
0360    * Cancelling the timer does not change the expiry time.
0361    *
0362    * @param ec Set to indicate what error occurred, if any.
0363    *
0364    * @return The number of asynchronous operations that were cancelled.
0365    *
0366    * @note If the timer has already expired when cancel() is called, then the
0367    * handlers for asynchronous wait operations will:
0368    *
0369    * @li have already been invoked; or
0370    *
0371    * @li have been queued for invocation in the near future.
0372    *
0373    * These handlers can no longer be cancelled, and therefore are passed an
0374    * error code that indicates the successful completion of the wait operation.
0375    */
0376   std::size_t cancel(boost::system::error_code& ec)
0377   {
0378     return impl_.get_service().cancel(impl_.get_implementation(), ec);
0379   }
0380 
0381   /// Cancels one asynchronous operation that is waiting on the timer.
0382   /**
0383    * This function forces the completion of one pending asynchronous wait
0384    * operation against the timer. Handlers are cancelled in FIFO order. The
0385    * handler for the cancelled operation will be invoked with the
0386    * boost::asio::error::operation_aborted error code.
0387    *
0388    * Cancelling the timer does not change the expiry time.
0389    *
0390    * @return The number of asynchronous operations that were cancelled. That is,
0391    * either 0 or 1.
0392    *
0393    * @throws boost::system::system_error Thrown on failure.
0394    *
0395    * @note If the timer has already expired when cancel_one() is called, then
0396    * the handlers for asynchronous wait operations will:
0397    *
0398    * @li have already been invoked; or
0399    *
0400    * @li have been queued for invocation in the near future.
0401    *
0402    * These handlers can no longer be cancelled, and therefore are passed an
0403    * error code that indicates the successful completion of the wait operation.
0404    */
0405   std::size_t cancel_one()
0406   {
0407     boost::system::error_code ec;
0408     std::size_t s = impl_.get_service().cancel_one(
0409         impl_.get_implementation(), ec);
0410     boost::asio::detail::throw_error(ec, "cancel_one");
0411     return s;
0412   }
0413 
0414   /// Cancels one asynchronous operation that is waiting on the timer.
0415   /**
0416    * This function forces the completion of one pending asynchronous wait
0417    * operation against the timer. Handlers are cancelled in FIFO order. The
0418    * handler for the cancelled operation will be invoked with the
0419    * boost::asio::error::operation_aborted error code.
0420    *
0421    * Cancelling the timer does not change the expiry time.
0422    *
0423    * @param ec Set to indicate what error occurred, if any.
0424    *
0425    * @return The number of asynchronous operations that were cancelled. That is,
0426    * either 0 or 1.
0427    *
0428    * @note If the timer has already expired when cancel_one() is called, then
0429    * the handlers for asynchronous wait operations will:
0430    *
0431    * @li have already been invoked; or
0432    *
0433    * @li have been queued for invocation in the near future.
0434    *
0435    * These handlers can no longer be cancelled, and therefore are passed an
0436    * error code that indicates the successful completion of the wait operation.
0437    */
0438   std::size_t cancel_one(boost::system::error_code& ec)
0439   {
0440     return impl_.get_service().cancel_one(impl_.get_implementation(), ec);
0441   }
0442 
0443   /// Get the timer's expiry time as an absolute time.
0444   /**
0445    * This function may be used to obtain the timer's current expiry time.
0446    * Whether the timer has expired or not does not affect this value.
0447    */
0448   time_type expires_at() const
0449   {
0450     return impl_.get_service().expires_at(impl_.get_implementation());
0451   }
0452 
0453   /// Set the timer's expiry time as an absolute time.
0454   /**
0455    * This function sets the expiry time. Any pending asynchronous wait
0456    * operations will be cancelled. The handler for each cancelled operation will
0457    * be invoked with the boost::asio::error::operation_aborted error code.
0458    *
0459    * @param expiry_time The expiry time to be used for the timer.
0460    *
0461    * @return The number of asynchronous operations that were cancelled.
0462    *
0463    * @throws boost::system::system_error Thrown on failure.
0464    *
0465    * @note If the timer has already expired when expires_at() is called, then
0466    * the handlers for asynchronous wait operations will:
0467    *
0468    * @li have already been invoked; or
0469    *
0470    * @li have been queued for invocation in the near future.
0471    *
0472    * These handlers can no longer be cancelled, and therefore are passed an
0473    * error code that indicates the successful completion of the wait operation.
0474    */
0475   std::size_t expires_at(const time_type& expiry_time)
0476   {
0477     boost::system::error_code ec;
0478     std::size_t s = impl_.get_service().expires_at(
0479         impl_.get_implementation(), expiry_time, ec);
0480     boost::asio::detail::throw_error(ec, "expires_at");
0481     return s;
0482   }
0483 
0484   /// Set the timer's expiry time as an absolute time.
0485   /**
0486    * This function sets the expiry time. Any pending asynchronous wait
0487    * operations will be cancelled. The handler for each cancelled operation will
0488    * be invoked with the boost::asio::error::operation_aborted error code.
0489    *
0490    * @param expiry_time The expiry time to be used for the timer.
0491    *
0492    * @param ec Set to indicate what error occurred, if any.
0493    *
0494    * @return The number of asynchronous operations that were cancelled.
0495    *
0496    * @note If the timer has already expired when expires_at() is called, then
0497    * the handlers for asynchronous wait operations will:
0498    *
0499    * @li have already been invoked; or
0500    *
0501    * @li have been queued for invocation in the near future.
0502    *
0503    * These handlers can no longer be cancelled, and therefore are passed an
0504    * error code that indicates the successful completion of the wait operation.
0505    */
0506   std::size_t expires_at(const time_type& expiry_time,
0507       boost::system::error_code& ec)
0508   {
0509     return impl_.get_service().expires_at(
0510         impl_.get_implementation(), expiry_time, ec);
0511   }
0512 
0513   /// Get the timer's expiry time relative to now.
0514   /**
0515    * This function may be used to obtain the timer's current expiry time.
0516    * Whether the timer has expired or not does not affect this value.
0517    */
0518   duration_type expires_from_now() const
0519   {
0520     return impl_.get_service().expires_from_now(impl_.get_implementation());
0521   }
0522 
0523   /// Set the timer's expiry time relative to now.
0524   /**
0525    * This function sets the expiry time. Any pending asynchronous wait
0526    * operations will be cancelled. The handler for each cancelled operation will
0527    * be invoked with the boost::asio::error::operation_aborted error code.
0528    *
0529    * @param expiry_time The expiry time to be used for the timer.
0530    *
0531    * @return The number of asynchronous operations that were cancelled.
0532    *
0533    * @throws boost::system::system_error Thrown on failure.
0534    *
0535    * @note If the timer has already expired when expires_from_now() is called,
0536    * then the handlers for asynchronous wait operations will:
0537    *
0538    * @li have already been invoked; or
0539    *
0540    * @li have been queued for invocation in the near future.
0541    *
0542    * These handlers can no longer be cancelled, and therefore are passed an
0543    * error code that indicates the successful completion of the wait operation.
0544    */
0545   std::size_t expires_from_now(const duration_type& expiry_time)
0546   {
0547     boost::system::error_code ec;
0548     std::size_t s = impl_.get_service().expires_from_now(
0549         impl_.get_implementation(), expiry_time, ec);
0550     boost::asio::detail::throw_error(ec, "expires_from_now");
0551     return s;
0552   }
0553 
0554   /// Set the timer's expiry time relative to now.
0555   /**
0556    * This function sets the expiry time. Any pending asynchronous wait
0557    * operations will be cancelled. The handler for each cancelled operation will
0558    * be invoked with the boost::asio::error::operation_aborted error code.
0559    *
0560    * @param expiry_time The expiry time to be used for the timer.
0561    *
0562    * @param ec Set to indicate what error occurred, if any.
0563    *
0564    * @return The number of asynchronous operations that were cancelled.
0565    *
0566    * @note If the timer has already expired when expires_from_now() is called,
0567    * then the handlers for asynchronous wait operations will:
0568    *
0569    * @li have already been invoked; or
0570    *
0571    * @li have been queued for invocation in the near future.
0572    *
0573    * These handlers can no longer be cancelled, and therefore are passed an
0574    * error code that indicates the successful completion of the wait operation.
0575    */
0576   std::size_t expires_from_now(const duration_type& expiry_time,
0577       boost::system::error_code& ec)
0578   {
0579     return impl_.get_service().expires_from_now(
0580         impl_.get_implementation(), expiry_time, ec);
0581   }
0582 
0583   /// Perform a blocking wait on the timer.
0584   /**
0585    * This function is used to wait for the timer to expire. This function
0586    * blocks and does not return until the timer has expired.
0587    *
0588    * @throws boost::system::system_error Thrown on failure.
0589    */
0590   void wait()
0591   {
0592     boost::system::error_code ec;
0593     impl_.get_service().wait(impl_.get_implementation(), ec);
0594     boost::asio::detail::throw_error(ec, "wait");
0595   }
0596 
0597   /// Perform a blocking wait on the timer.
0598   /**
0599    * This function is used to wait for the timer to expire. This function
0600    * blocks and does not return until the timer has expired.
0601    *
0602    * @param ec Set to indicate what error occurred, if any.
0603    */
0604   void wait(boost::system::error_code& ec)
0605   {
0606     impl_.get_service().wait(impl_.get_implementation(), ec);
0607   }
0608 
0609   /// Start an asynchronous wait on the timer.
0610   /**
0611    * This function may be used to initiate an asynchronous wait against the
0612    * timer. It is an initiating function for an @ref asynchronous_operation,
0613    * and always returns immediately.
0614    *
0615    * For each call to async_wait(), the completion handler will be called
0616    * exactly once. The completion handler will be called when:
0617    *
0618    * @li The timer has expired.
0619    *
0620    * @li The timer was cancelled, in which case the handler is passed the error
0621    * code boost::asio::error::operation_aborted.
0622    *
0623    * @param token The @ref completion_token that will be used to produce a
0624    * completion handler, which will be called when the timer expires. Potential
0625    * completion tokens include @ref use_future, @ref use_awaitable, @ref
0626    * yield_context, or a function object with the correct completion signature.
0627    * The function signature of the completion handler must be:
0628    * @code void handler(
0629    *   const boost::system::error_code& error // Result of operation.
0630    * ); @endcode
0631    * Regardless of whether the asynchronous operation completes immediately or
0632    * not, the completion handler will not be invoked from within this function.
0633    * On immediate completion, invocation of the handler will be performed in a
0634    * manner equivalent to using boost::asio::post().
0635    *
0636    * @par Completion Signature
0637    * @code void(boost::system::error_code) @endcode
0638    *
0639    * @par Per-Operation Cancellation
0640    * This asynchronous operation supports cancellation for the following
0641    * boost::asio::cancellation_type values:
0642    *
0643    * @li @c cancellation_type::terminal
0644    *
0645    * @li @c cancellation_type::partial
0646    *
0647    * @li @c cancellation_type::total
0648    */
0649   template <
0650       BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code))
0651         WaitToken = default_completion_token_t<executor_type>>
0652   auto async_wait(
0653       WaitToken&& token = default_completion_token_t<executor_type>())
0654     -> decltype(
0655       async_initiate<WaitToken, void (boost::system::error_code)>(
0656         declval<initiate_async_wait>(), token))
0657   {
0658     return async_initiate<WaitToken, void (boost::system::error_code)>(
0659         initiate_async_wait(this), token);
0660   }
0661 
0662 private:
0663   // Disallow copying and assignment.
0664   basic_deadline_timer(const basic_deadline_timer&) = delete;
0665   basic_deadline_timer& operator=(
0666       const basic_deadline_timer&) = delete;
0667 
0668   class initiate_async_wait
0669   {
0670   public:
0671     typedef Executor executor_type;
0672 
0673     explicit initiate_async_wait(basic_deadline_timer* self)
0674       : self_(self)
0675     {
0676     }
0677 
0678     const executor_type& get_executor() const noexcept
0679     {
0680       return self_->get_executor();
0681     }
0682 
0683     template <typename WaitHandler>
0684     void operator()(WaitHandler&& handler) const
0685     {
0686       // If you get an error on the following line it means that your handler
0687       // does not meet the documented type requirements for a WaitHandler.
0688       BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
0689 
0690       detail::non_const_lvalue<WaitHandler> handler2(handler);
0691       self_->impl_.get_service().async_wait(
0692           self_->impl_.get_implementation(),
0693           handler2.value, self_->impl_.get_executor());
0694     }
0695 
0696   private:
0697     basic_deadline_timer* self_;
0698   };
0699 
0700   detail::io_object_impl<
0701     detail::deadline_timer_service<TimeTraits>, Executor> impl_;
0702 };
0703 
0704 } // namespace asio
0705 } // namespace boost
0706 
0707 #include <boost/asio/detail/pop_options.hpp>
0708 
0709 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
0710        // || defined(GENERATING_DOCUMENTATION)
0711 
0712 #endif // BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP