Tor  0.4.7.0-alpha-dev
timers.h
Go to the documentation of this file.
1 /* Copyright (c) 2016-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * \file timers.h
6  * \brief Header for timers.c
7  **/
8 
9 #ifndef TOR_TIMERS_H
10 #define TOR_TIMERS_H
11 
12 #include "orconfig.h"
14 
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))
28 
29 void timers_initialize(void);
30 void timers_shutdown(void);
31 
32 #ifdef TOR_TIMERS_PRIVATE
33 STATIC void timers_run_pending(void);
34 #endif
35 
36 #endif /* !defined(TOR_TIMERS_H) */
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32
STATIC void timers_run_pending(void)
Definition: timers.c:173
void timer_set_cb(tor_timer_t *t, timer_cb_fn_t cb, void *arg)
Definition: timers.c:276
void timer_get_cb(const tor_timer_t *t, timer_cb_fn_t *cb_out, void **arg_out)
Definition: timers.c:287
void timers_shutdown(void)
Definition: timers.c:234
void timers_initialize(void)
Definition: timers.c:205
void timer_schedule(tor_timer_t *t, const struct timeval *delay)
Definition: timers.c:301
tor_timer_t * timer_new(timer_cb_fn_t cb, void *arg)
Definition: timers.c:250
void timer_disable(tor_timer_t *t)
Definition: timers.c:326
void timer_free_(tor_timer_t *t)
Definition: timers.c:263