uvw  2.8.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
uvw::TimerHandle::again
void again()
Stops the timer and restarts it if it was repeating.
uvw
uvw default namespace.
Definition: async.h:10
uvw::TimerHandle
The TimerHandle handle.
Definition: timer.h:29
uvw::TimerHandle::start
void start(Time timeout, Time repeat)
Starts the timer.
uvw::TimerHandle::repeat
void repeat(Time repeat)
Sets the repeat interval value.
uvw::TimerEvent
TimerEvent event.
Definition: timer.h:19
uvw::TimerHandle::stop
void stop()
Stops the handle.
uvw::Handle
Handle base class.
Definition: handle.hpp:30
uvw::TimerHandle::repeat
Time repeat()
Gets the timer repeat value.
uvw::TimerHandle::init
bool init()
Initializes the handle.
uvw::TimerHandle::dueIn
Time dueIn()
Gets the timer due value.