events_internal.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef EVENTS_INTERNAL_H_
  2. #define EVENTS_INTERNAL_H_
  3. #include <sys/time.h>
  4. #include <signal.h>
  5. /* Opaque event structure. */
  6. struct eventrec;
  7. /**
  8. * events_mkrec(func, cookie):
  9. * Package ${func}, ${cookie} into a struct eventrec.
  10. */
  11. struct eventrec * events_mkrec(int (*)(void *), void *);
  12. /**
  13. * events_freerec(r):
  14. * Free the eventrec ${r}.
  15. */
  16. void events_freerec(struct eventrec *);
  17. /**
  18. * events_immediate_get(void):
  19. * Remove and return an eventrec structure from the immediate event queue,
  20. * or return NULL if there are no such events. The caller is responsible for
  21. * freeing the returned memory.
  22. */
  23. struct eventrec * events_immediate_get(void);
  24. /**
  25. * events_network_select(tv, interrupt_requested):
  26. * Check for socket readiness events, waiting up to ${tv} time if there are
  27. * no sockets immediately ready, or indefinitely if ${tv} is NULL. The value
  28. * stored in ${tv} may be modified. If ${*interrupt_requested} is non-zero
  29. * and a signal is received, exit.
  30. */
  31. int events_network_select(const struct timeval *,
  32. const volatile sig_atomic_t *);
  33. /**
  34. * events_network_selectstats_startclock(void):
  35. * Start the inter-select duration clock: There is a selectable event.
  36. */
  37. void events_network_selectstats_startclock(void);
  38. /**
  39. * events_network_selectstats_stopclock(void):
  40. * Stop the inter-select duration clock: There are no selectable events.
  41. */
  42. void events_network_selectstats_stopclock(void);
  43. /**
  44. * events_network_selectstats_select(void):
  45. * Update inter-select duration statistics in relation to an upcoming
  46. * select(2) call.
  47. */
  48. void events_network_selectstats_select(void);
  49. /**
  50. * events_network_get(void):
  51. * Find a socket readiness event which was identified by a previous call to
  52. * events_network_select, and return it as an eventrec structure; or return
  53. * NULL if there are no such events available. The caller is responsible for
  54. * freeing the returned memory.
  55. */
  56. struct eventrec * events_network_get(void);
  57. /**
  58. * events_timer_min(timeo):
  59. * Return via ${timeo} a pointer to the minimum time which must be waited
  60. * before a timer will expire; or to NULL if there are no timers. The caller
  61. * is responsible for freeing the returned pointer.
  62. */
  63. int events_timer_min(struct timeval **);
  64. /**
  65. * events_timer_get(r):
  66. * Return via ${r} a pointer to an eventrec structure corresponding to an
  67. * expired timer, and delete said timer; or to NULL if there are no expired
  68. * timers. The caller is responsible for freeing the returned pointer.
  69. */
  70. int events_timer_get(struct eventrec **);
  71. #endif /* !EVENTS_INTERNAL_H_ */