iowatcher.h 781 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef IO_WATCHER_H_
  2. #define IO_WATCHER_H_
  3. #include "hloop.h"
  4. #include "hplatform.h"
  5. #if !defined(EVENT_SELECT) && \
  6. !defined(EVENT_EPOLL) && \
  7. !defined(EVENT_POLL) && \
  8. !defined(EVENT_KQUEUE) && \
  9. !defined(EVENT_IOCP) && \
  10. !defined(EVENT_PORT) && \
  11. !defined(EVENT_NOEVENT)
  12. #ifdef OS_WIN
  13. #define EVENT_IOCP
  14. #elif defined(OS_LINUX)
  15. #define EVENT_EPOLL
  16. #elif defined(OS_MAC)
  17. #define EVENT_KQUEUE
  18. #elif defined(OS_BSD)
  19. #define EVENT_KQUEUE
  20. #else
  21. #define EVENT_SELECT
  22. #endif
  23. #endif
  24. int iowatcher_init(hloop_t* loop);
  25. int iowatcher_cleanup(hloop_t* loop);
  26. int iowatcher_add_event(hloop_t* loop, int fd, int events);
  27. int iowatcher_del_event(hloop_t* loop, int fd, int events);
  28. int iowatcher_poll_events(hloop_t* loop, int timeout);
  29. #endif