fdm: add support for hooks

Hooks are functions executed just before going into a poll(). Or just
after executing all FD handlers, if you like.
This commit is contained in:
Daniel Eklöf 2020-01-04 19:48:15 +01:00
parent 14d897ac75
commit a3c18e72f5
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 53 additions and 0 deletions

4
fdm.h
View file

@ -5,6 +5,7 @@
struct fdm;
typedef bool (*fdm_handler_t)(struct fdm *fdm, int fd, int events, void *data);
typedef void (*fdm_hook_t)(struct fdm *fdm, void *data);
struct fdm *fdm_init(void);
void fdm_destroy(struct fdm *fdm);
@ -16,4 +17,7 @@ bool fdm_del_no_close(struct fdm *fdm, int fd);
bool fdm_event_add(struct fdm *fdm, int fd, int events);
bool fdm_event_del(struct fdm *fdm, int fd, int events);
bool fdm_hook_add(struct fdm *fdm, fdm_hook_t hook, void *data);
bool fdm_hook_del(struct fdm *fdm, fdm_hook_t hook);
bool fdm_poll(struct fdm *fdm);