uvw  2.10.0
timer.h
1 #ifndef UVW_TIMER_INCLUDE_H
2 #define UVW_TIMER_INCLUDE_H
3 
4 
5 #include <chrono>
6 #include <uv.h>
7 #include "handle.hpp"
8 #include "loop.h"
9 
10 
11 namespace uvw {
12 
13 
19 struct TimerEvent {};
20 
21 
29 class TimerHandle final: public Handle<TimerHandle, uv_timer_t> {
30  static void startCallback(uv_timer_t *handle);
31 
32 public:
33  using Time = std::chrono::duration<uint64_t, std::milli>;
34 
35  using Handle::Handle;
36 
41  bool init();
42 
55  void start(Time timeout, Time repeat);
56 
60  void stop();
61 
69  void again();
70 
89  void repeat(Time repeat);
90 
96  Time repeat();
97 
105  Time dueIn();
106 };
107 
108 
109 }
110 
111 
112 #ifndef UVW_AS_LIB
113 #include "timer.cpp"
114 #endif
115 
116 #endif // UVW_TIMER_INCLUDE_H
Handle base class.
Definition: handle.hpp:30
The TimerHandle handle.
Definition: timer.h:29
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:10
TimerEvent event.
Definition: timer.h:19