timers.h 1015 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* Copyright (c) 2016-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file timers.h
  5. * \brief Header for timers.c
  6. **/
  7. #ifndef TOR_TIMERS_H
  8. #define TOR_TIMERS_H
  9. #include "orconfig.h"
  10. #include "lib/testsupport/testsupport.h"
  11. struct monotime_t;
  12. typedef struct timeout tor_timer_t;
  13. typedef void (*timer_cb_fn_t)(tor_timer_t *, void *,
  14. const struct monotime_t *);
  15. tor_timer_t *timer_new(timer_cb_fn_t cb, void *arg);
  16. void timer_set_cb(tor_timer_t *t, timer_cb_fn_t cb, void *arg);
  17. void timer_get_cb(const tor_timer_t *t,
  18. timer_cb_fn_t *cb_out, void **arg_out);
  19. void timer_schedule(tor_timer_t *t, const struct timeval *delay);
  20. void timer_disable(tor_timer_t *t);
  21. void timer_free_(tor_timer_t *t);
  22. #define timer_free(t) FREE_AND_NULL(tor_timer_t, timer_free_, (t))
  23. void timers_initialize(void);
  24. void timers_shutdown(void);
  25. #ifdef TOR_TIMERS_PRIVATE
  26. STATIC void timers_run_pending(void);
  27. #endif
  28. #endif /* !defined(TOR_TIMERS_H) */