summaryrefslogtreecommitdiff
path: root/src/looper.hh
blob: 4dfe56fe4321716588ec8f5a716c25e0a1f9d139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef LOOPER_HH
#define LOOPER_HH

#include <functional>

class Looper {
public:
  virtual ~Looper() {}

  static uint8_t const EV_READ;
  static uint8_t const EV_WRITE;
  static uint8_t const EV_ERR;

  virtual void add(int fd, uint8_t events,
                   std::function<void(Looper*, int, uint8_t)>
                   const& callback) = 0;
  virtual void modify(int fd, uint8_t events) = 0;
  virtual void remove(int fd) = 0;

  // Returned id is never 0
  virtual uint32_t schedule(
      double delay, std::function<void(Looper*, uint32_t)> const& callback) = 0;
  virtual void cancel(uint32_t id) = 0;

protected:
  Looper() {}
  Looper(Looper const&) = delete;
  Looper& operator=(Looper const&) = delete;
};

#endif  // LOOPER_HH