26#ifndef MYSQL_HARNESS_NET_TS_TIMER_H_
27#define MYSQL_HARNESS_NET_TS_TIMER_H_
42 const typename Clock::duration &d) {
46 const typename Clock::time_point &tp) {
47 auto diff = tp - Clock::now();
49 if (
diff > Clock::duration::max())
return Clock::duration::max();
50 if (
diff < Clock::duration::min())
return Clock::duration::min();
56template <
class Clock,
class WaitTraits>
61 using duration =
typename clock_type::duration;
85 if (
this == std::addressof(rhs)) {
91 expiry_ = std::move(rhs.expiry_);
107 size_t cancelled =
cancel();
119 while (clock_type::now() <
expiry_) {
120 std::this_thread::sleep_for(traits_type::to_wait_duration(
expiry_));
126 template <
class CompletionToken>
131 std::move(
init.completion_handler));
133 return init.result.get();
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
Definition: executor.h:72
basic_waitable_timer(const basic_waitable_timer &)=delete
executor_type executor_
Definition: timer.h:137
~basic_waitable_timer()
Definition: timer.h:81
basic_waitable_timer(io_context &io_ctx)
Definition: timer.h:66
basic_waitable_timer & operator=(const basic_waitable_timer &)=delete
time_point expiry_
Definition: timer.h:138
basic_waitable_timer(io_context &io_ctx, const duration &d)
Definition: timer.h:70
Id * id() const
Definition: timer.h:146
basic_waitable_timer(basic_waitable_timer &&rhs)
Definition: timer.h:74
size_t cancel()
Definition: timer.h:101
time_point expiry() const
Definition: timer.h:104
basic_waitable_timer(io_context &io_ctx, const time_point &tp)
Definition: timer.h:68
typename clock_type::duration duration
Definition: timer.h:61
typename clock_type::time_point time_point
Definition: timer.h:62
auto async_wait(CompletionToken &&token)
Definition: timer.h:127
WaitTraits traits_type
Definition: timer.h:63
size_t expires_at(const time_point &t)
Definition: timer.h:106
executor_type get_executor() noexcept
Definition: timer.h:100
size_t cancel_one()
Definition: timer.h:102
size_t expires_after(const duration &d)
Definition: timer.h:114
basic_waitable_timer & operator=(basic_waitable_timer &&rhs)
Definition: timer.h:84
stdx::expected< void, std::error_code > wait()
Definition: timer.h:118
Clock clock_type
Definition: timer.h:60
std::unique_ptr< Id > id_
Definition: timer.h:148
Definition: io_context.h:990
io_context & context() const noexcept
Definition: io_context.h:1002
Definition: io_context.h:61
size_t cancel_one(const Timer &)
Definition: io_context.h:847
void async_wait(native_handle_type fd, impl::socket::wait_type wt, Op &&op)
Definition: io_context.h:483
stdx::expected< void, std::error_code > cancel(native_handle_type fd)
cancel all async-ops of a file-descriptor.
Definition: io_context.h:1087
Definition: expected.h:944
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1080
Header for compiler-dependent features.
Definition: gcs_xcom_synode.h:64
static Clock::duration to_wait_duration(const typename Clock::time_point &tp)
Definition: timer.h:45
static Clock::duration to_wait_duration(const typename Clock::duration &d)
Definition: timer.h:41