uvw 2.12.1
Loading...
Searching...
No Matches
timer.h
1#ifndef UVW_TIMER_INCLUDE_H
2#define UVW_TIMER_INCLUDE_H
3
4#include <cstdint>
5#include <chrono>
6#include <uv.h>
7#include "handle.hpp"
8#include "loop.h"
9
10namespace uvw {
11
17struct TimerEvent {};
18
26class TimerHandle final: public Handle<TimerHandle, uv_timer_t> {
27 static void startCallback(uv_timer_t *handle);
28
29public:
30 using Time = std::chrono::duration<uint64_t, std::milli>;
31
32 using Handle::Handle;
33
38 bool init();
39
52 void start(Time timeout, Time repeat);
53
57 void stop();
58
66 void again();
67
86 void repeat(Time repeat);
87
93 Time repeat();
94
102 Time dueIn();
103};
104
105} // namespace uvw
106
107#ifndef UVW_AS_LIB
108# include "timer.cpp"
109#endif
110
111#endif // UVW_TIMER_INCLUDE_H
Handle base class.
Definition handle.hpp:26
The TimerHandle handle.
Definition timer.h:26
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:17