5#ifndef WPINET_UV_TIMER_H_
6#define WPINET_UV_TIMER_H_
28 struct private_init {};
31 using Time = std::chrono::duration<uint64_t, std::milli>;
33 explicit Timer(
const private_init&) {}
34 ~Timer() noexcept override = default;
69 std::function<
void()> func) {
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition Signal.h:495
bool Invoke(F &&f, Args &&... args) const
Definition Handle.h:267
Handle.
Definition Handle.h:290
uv_timer_t * GetRaw() const noexcept
Definition Handle.h:305
Event loop.
Definition Loop.h:37
Timer handle.
Definition Timer.h:27
static void SingleShot(Loop &loop, Time timeout, std::function< void()> func)
Create a timer that calls a functor after a given time interval.
void SetRepeat(Time repeat)
Set the repeat interval value.
Definition Timer.h:119
static std::shared_ptr< Timer > Create(Loop &loop)
Create a timer handle.
sig::Signal timeout
Signal generated when the timeout event occurs.
Definition Timer.h:140
Time GetRepeat() const
Get the timer repeat value.
Definition Timer.h:126
static void SingleShot(const std::shared_ptr< Loop > &loop, Time timeout, std::function< void()> func)
Create a timer that calls a functor after a given time interval.
Definition Timer.h:68
Time GetDueIn() const
Get the timer due value or 0 if it has expired.
Definition Timer.h:135
Timer(const private_init &)
Definition Timer.h:33
void Stop()
Stop the timer.
Definition Timer.h:90
std::chrono::duration< uint64_t, std::milli > Time
Definition Timer.h:31
void Again()
Stop the timer and restart it if it was repeating.
Definition Timer.h:99
void Start(Time timeout, Time repeat=Time{0})
Start the timer.
~Timer() noexcept override=default
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
UV_EXTERN int uv_timer_stop(uv_timer_t *handle)
UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t *handle)
UV_EXTERN int uv_timer_again(uv_timer_t *handle)
UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t *handle)
UV_EXTERN void uv_timer_set_repeat(uv_timer_t *handle, uint64_t repeat)