diff options
Diffstat (limited to 'include/loop.h')
-rw-r--r-- | include/loop.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/include/loop.h b/include/loop.h index 7c151785..2f608eda 100644 --- a/include/loop.h +++ b/include/loop.h @@ -5,12 +5,12 @@ /** * This is an event loop system designed for sway clients, not sway itself. * - * It uses pollfds to block on multiple file descriptors at once, and provides - * an easy way to set timers. Typically the Wayland display's fd will be one of - * the fds in the loop. + * The loop consists of file descriptors and timers. Typically the Wayland + * display's file descriptor will be one of the fds in the loop. */ struct loop; +struct loop_timer; /** * Create an event loop. @@ -28,20 +28,27 @@ void loop_destroy(struct loop *loop); void loop_poll(struct loop *loop); /** - * Add an fd to the loop. + * Add a file descriptor to the loop. */ -struct loop_event *loop_add_fd(struct loop *loop, int fd, short mask, +void loop_add_fd(struct loop *loop, int fd, short mask, void (*func)(int fd, short mask, void *data), void *data); /** * Add a timer to the loop. + * + * When the timer expires, the timer will be removed from the loop and freed. + */ +struct loop_timer *loop_add_timer(struct loop *loop, int ms, + void (*callback)(void *data), void *data); + +/** + * Remove a file descriptor from the loop. */ -struct loop_event *loop_add_timer(struct loop *loop, int ms, - void (*callback)(int fd, short mask, void *data), void *data); +bool loop_remove_fd(struct loop *loop, int fd); /** - * Remove an event from the loop. + * Remove a timer from the loop. */ -bool loop_remove_event(struct loop *loop, struct loop_event *event); +bool loop_remove_timer(struct loop *loop, struct loop_timer *timer); #endif |