11 #ifndef ASIO_BASIC_WAITABLE_TIMER_HPP 12 #define ASIO_BASIC_WAITABLE_TIMER_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 20 #include "asio/any_io_executor.hpp" 21 #include "asio/detail/chrono_time_traits.hpp" 22 #include "asio/detail/deadline_timer_service.hpp" 23 #include "asio/detail/handler_type_requirements.hpp" 24 #include "asio/detail/io_object_impl.hpp" 25 #include "asio/detail/non_const_lvalue.hpp" 26 #include "asio/detail/throw_error.hpp" 27 #include "asio/error.hpp" 28 #include "asio/wait_traits.hpp" 30 #if defined(ASIO_HAS_MOVE) 32 #endif // defined(ASIO_HAS_MOVE) 34 #include "asio/detail/push_options.hpp" 38 #if !defined(ASIO_BASIC_WAITABLE_TIMER_FWD_DECL) 39 #define ASIO_BASIC_WAITABLE_TIMER_FWD_DECL 42 template <
typename Clock,
44 typename Executor = any_io_executor>
47 #endif // !defined(ASIO_BASIC_WAITABLE_TIMER_FWD_DECL) 141 template <
typename Clock,
typename WaitTraits,
typename Executor>
149 template <
typename Executor1>
192 template <
typename ExecutionContext>
195 is_convertible<ExecutionContext&, execution_context&>::value
215 impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
216 asio::detail::throw_error(ec,
"expires_at");
230 template <
typename ExecutionContext>
232 const time_point& expiry_time,
234 is_convertible<ExecutionContext&, execution_context&>::value
239 impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
240 asio::detail::throw_error(ec,
"expires_at");
257 impl_.get_service().expires_after(
258 impl_.get_implementation(), expiry_time, ec);
259 asio::detail::throw_error(ec,
"expires_after");
273 template <
typename ExecutionContext>
275 const duration& expiry_time,
277 is_convertible<ExecutionContext&, execution_context&>::value
282 impl_.get_service().expires_after(
283 impl_.get_implementation(), expiry_time, ec);
284 asio::detail::throw_error(ec,
"expires_after");
287 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 300 : impl_(std::move(
other.impl_))
318 impl_ = std::move(
other.impl_);
323 template <
typename Clock1,
typename WaitTraits1,
typename Executor1>
337 template <
typename Executor1>
341 is_convertible<Executor1, Executor>::value
343 : impl_(std::move(
other.impl_))
359 template <
typename Executor1>
361 is_convertible<Executor1, Executor>::value,
366 impl_ = std::move(tmp.impl_);
369 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 383 return impl_.get_executor();
411 std::size_t
s = impl_.get_service().cancel(impl_.get_implementation(), ec);
412 asio::detail::throw_error(ec,
"cancel");
416 #if !defined(ASIO_NO_DEPRECATED) 442 return impl_.get_service().cancel(impl_.get_implementation(), ec);
444 #endif // !defined(ASIO_NO_DEPRECATED) 473 std::size_t
s = impl_.get_service().cancel_one(
474 impl_.get_implementation(), ec);
475 asio::detail::throw_error(ec,
"cancel_one");
479 #if !defined(ASIO_NO_DEPRECATED) 507 return impl_.get_service().cancel_one(impl_.get_implementation(), ec);
518 return impl_.get_service().expires_at(impl_.get_implementation());
520 #endif // !defined(ASIO_NO_DEPRECATED) 529 return impl_.get_service().expiry(impl_.get_implementation());
557 std::size_t
s = impl_.get_service().expires_at(
558 impl_.get_implementation(), expiry_time, ec);
559 asio::detail::throw_error(ec,
"expires_at");
563 #if !defined(ASIO_NO_DEPRECATED) 590 return impl_.get_service().expires_at(
591 impl_.get_implementation(), expiry_time, ec);
593 #endif // !defined(ASIO_NO_DEPRECATED) 620 std::size_t
s = impl_.get_service().expires_after(
621 impl_.get_implementation(), expiry_time, ec);
622 asio::detail::throw_error(ec,
"expires_after");
626 #if !defined(ASIO_NO_DEPRECATED) 634 return impl_.get_service().expires_from_now(impl_.get_implementation());
663 std::size_t
s = impl_.get_service().expires_from_now(
664 impl_.get_implementation(), expiry_time, ec);
665 asio::detail::throw_error(ec,
"expires_from_now");
695 return impl_.get_service().expires_from_now(
696 impl_.get_implementation(), expiry_time, ec);
698 #endif // !defined(ASIO_NO_DEPRECATED) 710 impl_.get_service().wait(impl_.get_implementation(), ec);
711 asio::detail::throw_error(ec,
"wait");
723 impl_.get_service().wait(impl_.get_implementation(), ec);
752 WaitHandler ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
756 ASIO_MOVE_ARG(WaitHandler) handler
757 ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
759 return async_initiate<WaitHandler, void (asio::error_code)>(
760 initiate_async_wait(
this), handler);
769 class initiate_async_wait
781 return self_->get_executor();
784 template <
typename WaitHandler>
785 void operator()(ASIO_MOVE_ARG(WaitHandler) handler)
const 789 ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
792 self_->impl_.get_service().async_wait(
793 self_->impl_.get_implementation(),
794 handler2.value, self_->impl_.get_executor());
804 executor_type > impl_;
809 #include "asio/detail/pop_options.hpp" 811 #endif // ASIO_BASIC_WAITABLE_TIMER_HPP std::size_t cancel_one(asio::error_code &ec)
(Deprecated: Use non-error_code overload.) Cancels one asynchronous operation that is waiting on the ...
Definition: basic_waitable_timer.hpp:505
clock_type::duration duration
The duration type of the clock.
Definition: basic_waitable_timer.hpp:160
std::size_t expires_from_now(const duration &expiry_time)
(Deprecated: Use expires_after().) Set the timer's expiry time relative to now.
Definition: basic_waitable_timer.hpp:660
basic_waitable_timer(ExecutionContext &context, const time_point &expiry_time, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Constructor to set a particular expiry time as an absolute time.
Definition: basic_waitable_timer.hpp:231
Definition: deadline_timer_service.hpp:45
std::size_t cancel()
Cancel any asynchronous operations that are waiting on the timer.
Definition: basic_waitable_timer.hpp:408
std::size_t expires_from_now(const duration &expiry_time, asio::error_code &ec)
(Deprecated: Use expires_after().) Set the timer's expiry time relative to now.
Definition: basic_waitable_timer.hpp:692
Definition: blocking.hpp:208
Definition: chrono_time_traits.hpp:34
Rebinds the timer type to another executor.
Definition: basic_waitable_timer.hpp:150
void wait()
Perform a blocking wait on the timer.
Definition: basic_waitable_timer.hpp:707
time_point expiry() const
Get the timer's expiry time as an absolute time.
Definition: basic_waitable_timer.hpp:527
basic_waitable_timer(ExecutionContext &context, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Constructor.
Definition: basic_waitable_timer.hpp:193
basic_waitable_timer(ExecutionContext &context, const duration &expiry_time, typename enable_if< is_convertible< ExecutionContext &, execution_context &>::value >::type *=0)
Constructor to set a particular expiry time relative to now.
Definition: basic_waitable_timer.hpp:274
basic_waitable_timer< Clock, WaitTraits, Executor1 > other
The timer type when rebound to the specified executor.
Definition: basic_waitable_timer.hpp:153
time_point expires_at() const
(Deprecated: Use expiry().) Get the timer's expiry time as an absolute time.
Definition: basic_waitable_timer.hpp:516
std::size_t cancel_one()
Cancels one asynchronous operation that is waiting on the timer.
Definition: basic_waitable_timer.hpp:470
Definition: type_traits.hpp:97
Definition: non_const_lvalue.hpp:27
WaitTraits traits_type
The wait traits type.
Definition: basic_waitable_timer.hpp:166
Clock clock_type
The clock type.
Definition: basic_waitable_timer.hpp:157
executor_type get_executor() ASIO_NOEXCEPT
Get the executor associated with the object.
Definition: basic_waitable_timer.hpp:381
clock_type::time_point time_point
The time point type of the clock.
Definition: basic_waitable_timer.hpp:163
Wait traits suitable for use with the basic_waitable_timer class template.
Definition: netfwd.hpp:111
Class to represent an error code value.
Definition: error_code.hpp:80
Definition: io_object_impl.hpp:33
std::size_t cancel(asio::error_code &ec)
(Deprecated: Use non-error_code overload.) Cancel any asynchronous operations that are waiting on the...
Definition: basic_waitable_timer.hpp:440
Executor executor_type
The type of the executor associated with the object.
Definition: basic_waitable_timer.hpp:146
basic_waitable_timer(const executor_type &ex)
Constructor.
Definition: basic_waitable_timer.hpp:177
Provides waitable timer functionality.
Definition: basic_waitable_timer.hpp:45
ASIO_INITFN_AUTO_RESULT_TYPE(WaitHandler, void(asio::error_code)) async_wait(ASIO_MOVE_ARG(WaitHandler) handler ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
Start an asynchronous wait on the timer.
Definition: basic_waitable_timer.hpp:753
std::size_t expires_at(const time_point &expiry_time)
Set the timer's expiry time as an absolute time.
Definition: basic_waitable_timer.hpp:554
std::size_t expires_after(const duration &expiry_time)
Set the timer's expiry time relative to now.
Definition: basic_waitable_timer.hpp:617
basic_waitable_timer(const executor_type &ex, const time_point &expiry_time)
Constructor to set a particular expiry time as an absolute time.
Definition: basic_waitable_timer.hpp:211
Definition: any_io_executor.hpp:28
~basic_waitable_timer()
Destroys the timer.
Definition: basic_waitable_timer.hpp:376
void wait(asio::error_code &ec)
Perform a blocking wait on the timer.
Definition: basic_waitable_timer.hpp:721
basic_waitable_timer(const executor_type &ex, const duration &expiry_time)
Constructor to set a particular expiry time relative to now.
Definition: basic_waitable_timer.hpp:253
duration expires_from_now() const
(Deprecated: Use expiry().) Get the timer's expiry time relative to now.
Definition: basic_waitable_timer.hpp:632
std::size_t expires_at(const time_point &expiry_time, asio::error_code &ec)
(Deprecated: Use non-error_code overload.) Set the timer's expiry time as an absolute time...
Definition: basic_waitable_timer.hpp:587