![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/util/talloc.h>
Go to the source code of this file.
Data Structures | |
struct | fr_timer_list_pub_s |
Public event timer list structure. More... | |
Macros | |
#define | _CONST const |
#define | fr_timer_armed(_ev) ((_ev) && _fr_timer_armed(_ev)) /* returns true if the timer is armed */ |
#define | fr_timer_at(...) _fr_timer_at(NDEBUG_LOCATION_EXP __VA_ARGS__) |
#define | FR_TIMER_DELETE(_ev_p) |
#define | FR_TIMER_DELETE_RETURN(_ev_p) if ((likely((*(_ev_p)) != NULL) && unlikely(!fr_cond_assert_msg(fr_timer_delete(_ev_p) == 0, "Failed to delete timer %p", *(_ev_p))))) return -1; |
#define | FR_TIMER_DISARM(_ev) |
#define | FR_TIMER_DISARM_RETURN(_ev) if ((likely(((_ev)) != NULL) && unlikely(!fr_cond_assert_msg(fr_timer_disarm(_ev) == 0, "Failed to disarm timer %p", (_ev))))) return -1; |
#define | fr_timer_in(...) _fr_timer_in(NDEBUG_LOCATION_EXP __VA_ARGS__) |
Typedefs | |
typedef fr_time_t(* | fr_event_time_source_t) (void) |
Alternative time source, useful for testing. | |
typedef void(* | fr_timer_cb_t) (fr_timer_list_t *tl, fr_time_t now, void *uctx) |
Called when a timer event fires. | |
typedef struct fr_timer_list_pub_s | fr_timer_list_t |
typedef struct fr_timer_s | fr_timer_t |
An opaque timer handle. | |
Functions | |
bool | _fr_timer_armed (fr_timer_t *ev) |
Check if a timer event is armed. | |
int | _fr_timer_at (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_timer_list_t *tl, fr_timer_t **ev, fr_time_t when, bool free_on_fire, fr_timer_cb_t callback, void const *uctx) |
int | _fr_timer_in (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, fr_timer_list_t *tl, fr_timer_t **ev, fr_time_delta_t delta, bool free_on_fire, fr_timer_cb_t callback, void const *uctx) |
int | fr_timer_delete (fr_timer_t **ev_p) |
Delete a timer event and free its memory. | |
int | fr_timer_disarm (fr_timer_t *ev) |
Remove an event from the event list, but don't free the memory. | |
int | fr_timer_list_disarm (fr_timer_list_t *tl) |
Disable all timers in a list. | |
int | fr_timer_list_force_run (fr_timer_list_t *tl) |
Get the head of the timer list, the event may not be ready to fire. | |
fr_timer_list_t * | fr_timer_list_lst_alloc (TALLOC_CTX *ctx, fr_timer_list_t *parent) |
Allocate a new lst based timer list. | |
uint64_t | fr_timer_list_num_events (fr_timer_list_t *tl) |
Return number of pending events. | |
fr_timer_list_t * | fr_timer_list_ordered_alloc (TALLOC_CTX *ctx, fr_timer_list_t *parent) |
Allocate a new sorted event timer list. | |
int | fr_timer_list_run (fr_timer_list_t *tl, fr_time_t *when) |
Execute any pending events in the event loop. | |
void | fr_timer_list_set_time_func (fr_timer_list_t *tl, fr_event_time_source_t func) |
Override event list time source. | |
fr_time_t | fr_timer_list_when (fr_timer_list_t *tl) |
Return the time of the next event. | |
fr_time_t | fr_timer_when (fr_timer_t *ev) |
Internal timestamp representing when the timer should fire. | |
int | NDEBUG_LOCATION_NONNULL (3) |
int | NDEBUG_LOCATION_NONNULL (6))) |
struct fr_timer_list_pub_s |
Public event timer list structure.
Make the current list time, and time source available, but nothing else.
This allows us to access these values without the cost of a function call.
Data Fields | ||
---|---|---|
fr_event_time_source_t _CONST | time | Time source this list uses to get the current time when calculating deltas (fr_timer_in). |
#define fr_timer_armed | ( | _ev | ) | ((_ev) && _fr_timer_armed(_ev)) /* returns true if the timer is armed */ |
#define fr_timer_at | ( | ... | ) | _fr_timer_at(NDEBUG_LOCATION_EXP __VA_ARGS__) |
#define FR_TIMER_DELETE | ( | _ev_p | ) |
#define FR_TIMER_DELETE_RETURN | ( | _ev_p | ) | if ((likely((*(_ev_p)) != NULL) && unlikely(!fr_cond_assert_msg(fr_timer_delete(_ev_p) == 0, "Failed to delete timer %p", *(_ev_p))))) return -1; |
#define FR_TIMER_DISARM | ( | _ev | ) |
#define FR_TIMER_DISARM_RETURN | ( | _ev | ) | if ((likely(((_ev)) != NULL) && unlikely(!fr_cond_assert_msg(fr_timer_disarm(_ev) == 0, "Failed to disarm timer %p", (_ev))))) return -1; |
#define fr_timer_in | ( | ... | ) | _fr_timer_in(NDEBUG_LOCATION_EXP __VA_ARGS__) |
typedef fr_time_t(* fr_event_time_source_t) (void) |
typedef void(* fr_timer_cb_t) (fr_timer_list_t *tl, fr_time_t now, void *uctx) |
Called when a timer event fires.
[in] | tl | timer list event was inserted into. |
[in] | now | The current time. |
[in] | uctx | User ctx passed to fr_timer_in or fr_timer_at. |
typedef struct fr_timer_list_pub_s fr_timer_list_t |
typedef struct fr_timer_s fr_timer_t |
bool _fr_timer_armed | ( | fr_timer_t * | ev | ) |
int _fr_timer_at | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_timer_list_t * | tl, | ||
fr_timer_t ** | ev, | ||
fr_time_t | when, | ||
bool | free_on_fire, | ||
fr_timer_cb_t | callback, | ||
void const * | uctx | ||
) |
int _fr_timer_in | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
fr_timer_list_t * | tl, | ||
fr_timer_t ** | ev, | ||
fr_time_delta_t | delta, | ||
bool | free_on_fire, | ||
fr_timer_cb_t | callback, | ||
void const * | uctx | ||
) |
int fr_timer_delete | ( | fr_timer_t ** | ev_p | ) |
int fr_timer_disarm | ( | fr_timer_t * | ev | ) |
int fr_timer_list_disarm | ( | fr_timer_list_t * | tl | ) |
int fr_timer_list_force_run | ( | fr_timer_list_t * | tl | ) |
Get the head of the timer list, the event may not be ready to fire.
This is used to forcefully run every event in the event loop.
We pass in the real time, which may theoretically cause issues if timer callbacks are checking... But the uses of this function are very limited.
Definition at line 812 of file timer.c.
fr_timer_list_t * fr_timer_list_lst_alloc | ( | TALLOC_CTX * | ctx, |
fr_timer_list_t * | parent | ||
) |
uint64_t fr_timer_list_num_events | ( | fr_timer_list_t * | tl | ) |
fr_timer_list_t * fr_timer_list_ordered_alloc | ( | TALLOC_CTX * | ctx, |
fr_timer_list_t * | parent | ||
) |
int fr_timer_list_run | ( | fr_timer_list_t * | tl, |
fr_time_t * | when | ||
) |
Execute any pending events in the event loop.
[in] | tl | to execute events in. |
[in] | when | Process events scheduled to run before or at this time.
|
Definition at line 830 of file timer.c.
void fr_timer_list_set_time_func | ( | fr_timer_list_t * | tl, |
fr_event_time_source_t | func | ||
) |
fr_time_t fr_timer_list_when | ( | fr_timer_list_t * | tl | ) |
fr_time_t fr_timer_when | ( | fr_timer_t * | ev | ) |
int NDEBUG_LOCATION_NONNULL | ( | 3 | ) |
int NDEBUG_LOCATION_NONNULL | ( | 6 | ) |