uvw 3.4.0
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
13struct timer_event {};
14
22class timer_handle final: public handle<timer_handle, uv_timer_t, timer_event> {
23 static void start_callback(uv_timer_t *hndl);
24
25public:
26 using time = std::chrono::duration<uint64_t, std::milli>;
27
28 using handle::handle;
29
34 int init();
35
50 int start(time timeout, time repeat);
51
56 int stop();
57
66 int again();
67
86 void repeat(time repeat);
87
93 time repeat();
94
102 time due_in();
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:23
The timer handle.
Definition timer.h:22
void repeat(time repeat)
Sets the repeat interval value.
int stop()
Stops the handle.
int init()
Initializes the handle.
int again()
Stops the timer and restarts it if it was repeating.
time due_in()
Gets the timer due value.
time repeat()
Gets the timer repeat value.
int start(time timeout, time repeat)
Starts the timer.
uvw default namespace.
Definition async.h:8
Timer event.
Definition timer.h:13