24 #ifndef LELY_IO2_USER_TIMER_HPP_ 25 #define LELY_IO2_USER_TIMER_HPP_ 43 if (!timer) util::throw_errc(
"UserTimer");
49 other.timer =
nullptr;
58 swap(timer, other.timer);
67 template <class T, class U = typename ::std::decay<T>::type>
69 typename ::std::enable_if<compat::is_invocable<U, const timespec*>::value,
72 ::std::reference_wrapper<T> obj) {
74 [](
const timespec* tp,
void* arg) noexcept {
75 auto* obj =
static_cast<T*
>(arg);
78 static_cast<void*
>(
const_cast<U*
>(&obj.get())));
81 template <class T, class U = typename ::std::decay<T>::type>
82 inline typename ::std::enable_if<
86 ::std::reference_wrapper<T> obj) {
88 [](
const timespec* tp,
void* arg) noexcept {
89 auto* obj =
static_cast<T*
>(arg);
90 (*obj)(UserTimer::time_point{util::from_timespec(*tp)});
92 static_cast<void*
>(
const_cast<U*
>(&obj.get())));
95 template <
class C,
void (C::*M)(const timespec*)>
99 [](
const timespec* tp,
void* arg) noexcept {
100 auto obj =
static_cast<C*
>(arg);
103 static_cast<void*
>(obj));
106 template <
class C,
void (C::*M)(const UserTimer::time_po
int&)>
110 [](
const timespec* tp,
void* arg) noexcept {
111 auto obj =
static_cast<C*
>(arg);
112 (obj->*M)(UserTimer::time_point{util::from_timespec(*tp)});
114 static_cast<void*
>(obj));
120 #endif // !LELY_IO2_USER_TIMER_HPP_ A reference to an abstract timer.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Determines whether F can be invoked with the arguments Args....
io_timer_t * io_user_timer_create(io_ctx_t *ctx, ev_exec_t *exec, io_user_timer_setnext_t *func, void *arg)
Creates a new user-defined timer.
This header file is part of the I/O library; it contains the user-defined timer declarations.
void io_user_timer_setnext_t(const struct timespec *tp, void *arg)
The type of function invoked by a user-defined timer when the expiration time is updated with io_time...
void io_user_timer_destroy(io_timer_t *timer)
Destroys a user-defined timer.
This header file is part of the I/O library; it contains the C++ interface for the abstract timer...
This header file is part of the compatibility library; it includes <type_traits> and defines any miss...
UserTimer(io_ctx_t *ctx, ev_exec_t *exec, io_user_timer_setnext_t *func=nullptr, void *arg=nullptr)