aboutsummaryrefslogtreecommitdiffstats
path: root/include/loop.h
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-14 12:28:38 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-15 00:26:27 +1000
commit6921fdc6d6134fd7aaf38ffc1686623eca9bbd18 (patch)
tree0cbafde1d61ba4282e3ca73b4a312b9e82db25f9 /include/loop.h
parentswaylock: Don't wait too long for surface damage before verifying (diff)
downloadsway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.tar.gz
sway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.tar.zst
sway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.zip
Remove timerfd from loop implementation
timerfd doesn't work on the BSDs, so this replaces it with a timespec for the expiry and uses a poll timeout to check the timers when needed.
Diffstat (limited to 'include/loop.h')
-rw-r--r--include/loop.h25
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 @@
5/** 5/**
6 * This is an event loop system designed for sway clients, not sway itself. 6 * This is an event loop system designed for sway clients, not sway itself.
7 * 7 *
8 * It uses pollfds to block on multiple file descriptors at once, and provides 8 * The loop consists of file descriptors and timers. Typically the Wayland
9 * an easy way to set timers. Typically the Wayland display's fd will be one of 9 * display's file descriptor will be one of the fds in the loop.
10 * the fds in the loop.
11 */ 10 */
12 11
13struct loop; 12struct loop;
13struct loop_timer;
14 14
15/** 15/**
16 * Create an event loop. 16 * Create an event loop.
@@ -28,20 +28,27 @@ void loop_destroy(struct loop *loop);
28void loop_poll(struct loop *loop); 28void loop_poll(struct loop *loop);
29 29
30/** 30/**
31 * Add an fd to the loop. 31 * Add a file descriptor to the loop.
32 */ 32 */
33struct loop_event *loop_add_fd(struct loop *loop, int fd, short mask, 33void loop_add_fd(struct loop *loop, int fd, short mask,
34 void (*func)(int fd, short mask, void *data), void *data); 34 void (*func)(int fd, short mask, void *data), void *data);
35 35
36/** 36/**
37 * Add a timer to the loop. 37 * Add a timer to the loop.
38 *
39 * When the timer expires, the timer will be removed from the loop and freed.
40 */
41struct loop_timer *loop_add_timer(struct loop *loop, int ms,
42 void (*callback)(void *data), void *data);
43
44/**
45 * Remove a file descriptor from the loop.
38 */ 46 */
39struct loop_event *loop_add_timer(struct loop *loop, int ms, 47bool loop_remove_fd(struct loop *loop, int fd);
40 void (*callback)(int fd, short mask, void *data), void *data);
41 48
42/** 49/**
43 * Remove an event from the loop. 50 * Remove a timer from the loop.
44 */ 51 */
45bool loop_remove_event(struct loop *loop, struct loop_event *event); 52bool loop_remove_timer(struct loop *loop, struct loop_timer *timer);
46 53
47#endif 54#endif