uvw  1.3.0
idle.hpp
1 #pragma once
2 
3 
4 #include <utility>
5 #include <memory>
6 #include <uv.h>
7 #include "handle.hpp"
8 #include "loop.hpp"
9 
10 
11 namespace uvw {
12 
13 
19 struct IdleEvent {};
20 
21 
37 class IdleHandle final: public Handle<IdleHandle, uv_idle_t> {
38  static void startCallback(uv_idle_t *handle) {
39  IdleHandle &idle = *(static_cast<IdleHandle*>(handle->data));
40  idle.publish(IdleEvent{});
41  }
42 
43 public:
44  using Handle::Handle;
45 
50  bool init() {
51  return initialize(&uv_idle_init);
52  }
53 
60  void start() {
61  invoke(&uv_idle_start, get(), &startCallback);
62  }
63 
67  void stop() {
68  invoke(&uv_idle_stop, get());
69  }
70 };
71 
72 
73 }
void start()
Starts the handle.
Definition: idle.hpp:60
void stop()
Stops the handle.
Definition: idle.hpp:67
Handle base class.
Definition: handle.hpp:29
bool init()
Initializes the handle.
Definition: idle.hpp:50
The IdleHandle handle.
Definition: idle.hpp:37
IdleEvent event.
Definition: idle.hpp:19
uvw default namespace.
Definition: async.hpp:11