ustream: prevent recursive calls to the read callback
[project/libubox.git] / uloop.h
diff --git a/uloop.h b/uloop.h
index ab6149f514e58c90d88d1759777fc9634a0f94e2..4313dfea1f3f8d74408c7294b71ef710aa6d2ccf 100644 (file)
--- a/uloop.h
+++ b/uloop.h
 struct uloop_fd;
 struct uloop_timeout;
 struct uloop_process;
+struct uloop_interval;
+struct uloop_signal;
 
 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);
+typedef void (*uloop_signal_handler)(struct uloop_signal *s);
 
 #define ULOOP_READ             (1 << 0)
 #define ULOOP_WRITE            (1 << 1)
@@ -83,20 +87,54 @@ 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;
+       } priv;
+};
+
+struct uloop_signal
+{
+       struct list_head list;
+       struct sigaction orig;
+       bool pending;
+
+       uloop_signal_handler cb;
+       int signo;
+};
+
 extern bool uloop_cancelled;
 extern bool uloop_handle_sigchld;
+extern uloop_fd_handler uloop_fd_set_cb;
 
 int uloop_fd_add(struct uloop_fd *sock, unsigned int flags);
 int uloop_fd_delete(struct uloop_fd *sock);
 
+int uloop_get_next_timeout(void);
 int uloop_timeout_add(struct uloop_timeout *timeout);
 int uloop_timeout_set(struct uloop_timeout *timeout, int msecs);
 int uloop_timeout_cancel(struct uloop_timeout *timeout);
-int64_t uloop_timeout_remaining(struct uloop_timeout *timeout);
+int uloop_timeout_remaining(struct uloop_timeout *timeout) __attribute__((deprecated("use uloop_timeout_remaining64")));
+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);
+
+int uloop_signal_add(struct uloop_signal *s);
+int uloop_signal_delete(struct uloop_signal *s);
+
 bool uloop_cancelling(void);
 
 static inline void uloop_end(void)