1
0

iowatcher.h 919 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #if WITH_WEPOLL
  14. #define EVENT_EPOLL // wepoll -> iocp
  15. #else
  16. #define EVENT_POLL // WSAPoll
  17. #endif
  18. #elif defined(OS_LINUX)
  19. #define EVENT_EPOLL
  20. #elif defined(OS_MAC)
  21. #define EVENT_KQUEUE
  22. #elif defined(OS_BSD)
  23. #define EVENT_KQUEUE
  24. #elif defined(OS_SOLARIS)
  25. #define EVENT_PORT
  26. #else
  27. #define EVENT_SELECT
  28. #endif
  29. #endif
  30. int iowatcher_init(hloop_t* loop);
  31. int iowatcher_cleanup(hloop_t* loop);
  32. int iowatcher_add_event(hloop_t* loop, int fd, int events);
  33. int iowatcher_del_event(hloop_t* loop, int fd, int events);
  34. int iowatcher_poll_events(hloop_t* loop, int timeout);
  35. #endif