uvw 2.12.1
timer.h
1#ifndef UVW_TIMER_INCLUDE_H
2#define UVW_TIMER_INCLUDE_H
3
4#include <chrono>
5#include <uv.h>
6#include "handle.hpp"
7#include "loop.h"
8
9namespace uvw {
10
16struct TimerEvent {};
17
25class TimerHandle final: public Handle<TimerHandle, uv_timer_t> {
26 static void startCallback(uv_timer_t *handle);
27
28public:
29 using Time = std::chrono::duration<uint64_t, std::milli>;
30
31 using Handle::Handle;
32
37 bool init();
38
51 void start(Time timeout, Time repeat);
52
56 void stop();
57
65 void again();
66
85 void repeat(Time repeat);
86
92 Time repeat();
93
101 Time dueIn();
102};
103
104} // namespace uvw
105
106#ifndef UVW_AS_LIB
107# include "timer.cpp"
108#endif
109
110#endif // UVW_TIMER_INCLUDE_H
Handle base class.
Definition: handle.hpp:26
The TimerHandle handle.
Definition: timer.h:25
void stop()
Stops the handle.
void repeat(Time repeat)
Sets the repeat interval value.
void again()
Stops the timer and restarts it if it was repeating.
Time dueIn()
Gets the timer due value.
void start(Time timeout, Time repeat)
Starts the timer.
Time repeat()
Gets the timer repeat value.
bool init()
Initializes the handle.
uvw default namespace.
Definition: async.h:8
TimerEvent event.
Definition: timer.h:16