Merge branch 'tor-gitlab/mr/583' into maint-0.4.7
[tor.git] / src / lib / evloop / timers.h
blobb1fe017a0c8bc6c77117d5ed77f0db3fec9cc091
1 /* Copyright (c) 2016-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 /**
5 * \file timers.h
6 * \brief Header for timers.c
7 **/
9 #ifndef TOR_TIMERS_H
10 #define TOR_TIMERS_H
12 #include "orconfig.h"
13 #include "lib/testsupport/testsupport.h"
15 struct monotime_t;
16 struct timeval;
17 typedef struct timeout tor_timer_t;
18 typedef void (*timer_cb_fn_t)(tor_timer_t *, void *,
19 const struct monotime_t *);
20 tor_timer_t *timer_new(timer_cb_fn_t cb, void *arg);
21 void timer_set_cb(tor_timer_t *t, timer_cb_fn_t cb, void *arg);
22 void timer_get_cb(const tor_timer_t *t,
23 timer_cb_fn_t *cb_out, void **arg_out);
24 void timer_schedule(tor_timer_t *t, const struct timeval *delay);
25 void timer_disable(tor_timer_t *t);
26 void timer_free_(tor_timer_t *t);
27 #define timer_free(t) FREE_AND_NULL(tor_timer_t, timer_free_, (t))
29 void timers_initialize(void);
30 void timers_shutdown(void);
32 #ifdef TOR_TIMERS_PRIVATE
33 STATIC void timers_run_pending(void);
34 #endif
36 #endif /* !defined(TOR_TIMERS_H) */