eloop.h 961 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /** @file eloop.h
  2. * @brief Public interface for Event Loop.
  3. */
  4. #ifndef _faux_eloop_h
  5. #define _faux_eloop_h
  6. #include <faux/faux.h>
  7. typedef struct faux_eloop_s faux_eloop_t;
  8. typedef enum {
  9. FAUX_ELOOP_NULL = 0,
  10. FAUX_ELOOP_SIGNAL = 1,
  11. FAUX_ELOOP_SCHED = 2,
  12. FAUX_ELOOP_FD = 3
  13. } faux_eloop_type_e;
  14. typedef bool_t faux_eloop_cb_f(faux_eloop_t *eloop, faux_eloop_type_e type,
  15. void *associated_data, void *user_data);
  16. typedef struct {
  17. int ev_id;
  18. } faux_eloop_info_sched_t;
  19. typedef struct {
  20. int fd;
  21. short revents;
  22. } faux_eloop_info_fd_t;
  23. typedef struct {
  24. int signo;
  25. } faux_eloop_info_signal_t;
  26. C_DECL_BEGIN
  27. faux_eloop_t *faux_eloop_new(faux_eloop_cb_f *default_event_cb);
  28. void faux_eloop_free(faux_eloop_t *eloop);
  29. bool_t faux_eloop_loop(faux_eloop_t *eloop);
  30. bool_t faux_eloop_add_fd(faux_eloop_t *eloop, int fd, short events,
  31. faux_eloop_cb_f *event_cb, void *user_data);
  32. bool_t faux_eloop_del_fd(faux_eloop_t *eloop, int fd);
  33. C_DECL_END
  34. #endif