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) {
75 [](
const timespec* tp,
void* arg) noexcept {
76 auto* obj =
static_cast<T*
>(arg);
79 static_cast<void*
>(
const_cast<U*
>(&obj.get())));
82 template <class T, class U = typename ::std::decay<T>::type>
83 inline typename ::std::enable_if<
84 compat::is_invocable<U, const UserTimer::time_point&>::value,
87 ::std::reference_wrapper<T> obj) {
90 [](
const timespec* tp,
void* arg) noexcept {
91 auto* obj =
static_cast<T*
>(arg);
92 (*obj)(UserTimer::time_point{util::from_timespec(*tp)});
94 static_cast<void*
>(
const_cast<U*
>(&obj.get())));
97 template <
class C,
void (C::*M)(const timespec*)>
102 [](
const timespec* tp,
void* arg) noexcept {
103 auto obj =
static_cast<C*
>(arg);
106 static_cast<void*
>(obj));
109 template <
class C,
void (C::*M)(const UserTimer::time_po
int&)>
114 [](
const timespec* tp,
void* arg) noexcept {
115 auto obj =
static_cast<C*
>(arg);
116 (obj->*M)(UserTimer::time_point{util::from_timespec(*tp)});
118 static_cast<void*
>(obj));
124 #endif // !LELY_IO2_USER_TIMER_HPP_