uloop: add support for interval timers
[project/libubox.git] / uloop.h
diff --git a/uloop.h b/uloop.h
index 4fdd43f5084d438daaef17852824db57761ea124..b3f268c069ae10dd39aeb78eb11e1cb27746ef21 100644 (file)
--- a/uloop.h
+++ b/uloop.h
 struct uloop_fd;
 struct uloop_timeout;
 struct uloop_process;
+struct uloop_interval;
 
 typedef void (*uloop_fd_handler)(struct uloop_fd *u, unsigned int events);
 typedef void (*uloop_timeout_handler)(struct uloop_timeout *t);
 typedef void (*uloop_process_handler)(struct uloop_process *c, int ret);
+typedef void (*uloop_interval_handler)(struct uloop_interval *t);
 
 #define ULOOP_READ             (1 << 0)
 #define ULOOP_WRITE            (1 << 1)
@@ -83,6 +85,20 @@ struct uloop_process
        pid_t pid;
 };
 
+struct uloop_interval
+{
+       uloop_interval_handler cb;
+       uint64_t expirations;
+
+       union {
+               struct uloop_fd ufd;
+               struct {
+                       int64_t fired;
+                       unsigned int msecs;
+               } time;
+       } private;
+};
+
 extern bool uloop_cancelled;
 extern bool uloop_handle_sigchld;
 extern uloop_fd_handler uloop_fd_set_cb;
@@ -100,6 +116,10 @@ int64_t uloop_timeout_remaining64(struct uloop_timeout *timeout);
 int uloop_process_add(struct uloop_process *p);
 int uloop_process_delete(struct uloop_process *p);
 
+int uloop_interval_set(struct uloop_interval *timer, unsigned int msecs);
+int uloop_interval_cancel(struct uloop_interval *timer);
+int64_t uloop_interval_remaining(struct uloop_interval *timer);
+
 bool uloop_cancelling(void);
 
 static inline void uloop_end(void)