waiter: Don't rely on global variables to keep waiter state
[petitboot] / lib / waiter / waiter.h
1 #ifndef _WAITER_H
2 #define _WAITER_H
3
4 #include <poll.h>
5
6 struct waiter;
7 struct waitset;
8
9 enum events {
10         WAIT_IN  = POLLIN,
11         WAIT_OUT = POLLOUT,
12 };
13
14 typedef int (*waiter_cb)(void *);
15
16 struct waitset *waitset_create(void *ctx);
17 void waitset_destroy(struct waitset *waitset);
18
19 struct waiter *waiter_register(struct waitset *waitset, int fd, int events,
20                 waiter_cb callback, void *arg);
21
22 void waiter_remove(struct waiter *waiter);
23
24 int waiter_poll(struct waitset *waitset);
25 #endif /* _WAITER_H */
26
27