tor  0.4.2.1-alpha-dev
Macros | Typedefs | Functions
timers.h File Reference
#include "orconfig.h"
#include "lib/testsupport/testsupport.h"

Go to the source code of this file.

Macros

#define timer_free(t)   FREE_AND_NULL(tor_timer_t, timer_free_, (t))
 

Typedefs

typedef struct timeout tor_timer_t
 
typedef void(* timer_cb_fn_t) (tor_timer_t *, void *, const struct monotime_t *)
 

Functions

tor_timer_t * timer_new (timer_cb_fn_t cb, void *arg)
 
void timer_set_cb (tor_timer_t *t, timer_cb_fn_t cb, void *arg)
 
void timer_get_cb (const tor_timer_t *t, timer_cb_fn_t *cb_out, void **arg_out)
 
void timer_schedule (tor_timer_t *t, const struct timeval *delay)
 
void timer_disable (tor_timer_t *t)
 
void timer_free_ (tor_timer_t *t)
 
void timers_initialize (void)
 
void timers_shutdown (void)
 

Detailed Description

Header for timers.c.

Definition in file timers.h.

Function Documentation

◆ timer_disable()

void timer_disable ( tor_timer_t *  t)

Cancel the timer t if it is currently scheduled. (It's okay to call this on an unscheduled timer.

Definition at line 324 of file timers.c.

◆ timer_free_()

void timer_free_ ( tor_timer_t *  t)

Release all storage held by t, and unschedule it if was already scheduled.

Definition at line 261 of file timers.c.

◆ timer_get_cb()

void timer_get_cb ( const tor_timer_t *  t,
timer_cb_fn_t *  cb_out,
void **  arg_out 
)

Set *cb_out (if provided) to this timer's callback function, and *arg_out (if provided) to this timer's callback argument.

Definition at line 285 of file timers.c.

◆ timer_new()

tor_timer_t* timer_new ( timer_cb_fn_t  cb,
void *  arg 
)

Allocate and return a new timer, with given callback and argument.

Definition at line 248 of file timers.c.

◆ timer_schedule()

void timer_schedule ( tor_timer_t *  t,
const struct timeval tv 
)

Schedule the timer t to fire at the current time plus a delay of delay microseconds. All times are relative to monotime_get().

Definition at line 299 of file timers.c.

References monotime_get(), timer_advance_to_cur_time(), and tv_to_timeout().

◆ timer_set_cb()

void timer_set_cb ( tor_timer_t *  t,
timer_cb_fn_t  cb,
void *  arg 
)

Change the callback and argument associated with a timer t.

Definition at line 274 of file timers.c.

◆ timers_initialize()

void timers_initialize ( void  )

Initialize the timers subsystem. Requires that libevent has already been initialized.

Definition at line 203 of file timers.c.

◆ timers_shutdown()

void timers_shutdown ( void  )

Release all storage held in the timers subsystem. Does not fire timers.

Definition at line 232 of file timers.c.