1
0

iowatcher.h 866 B

123456789101112131415161718192021222324252627282930313233343536
  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_POLL) && \
  7. !defined(EVENT_EPOLL) && \
  8. !defined(EVENT_KQUEUE) && \
  9. !defined(EVENT_IOCP) && \
  10. !defined(EVENT_PORT) && \
  11. !defined(EVENT_NOEVENT)
  12. #ifdef OS_WIN
  13. // #define EVENT_IOCP // IOCP improving
  14. #define EVENT_POLL
  15. #elif defined(OS_LINUX)
  16. #define EVENT_EPOLL
  17. #elif defined(OS_MAC)
  18. #define EVENT_KQUEUE
  19. #elif defined(OS_BSD)
  20. #define EVENT_KQUEUE
  21. #elif defined(OS_SOLARIS)
  22. #define EVENT_PORT
  23. #else
  24. #define EVENT_SELECT
  25. #endif
  26. #endif
  27. int iowatcher_init(hloop_t* loop);
  28. int iowatcher_cleanup(hloop_t* loop);
  29. int iowatcher_add_event(hloop_t* loop, int fd, int events);
  30. int iowatcher_del_event(hloop_t* loop, int fd, int events);
  31. int iowatcher_poll_events(hloop_t* loop, int timeout);
  32. #endif