17 #error do not include tw_timer_template.h directly 25 #define _twt(a,b) a##b##_t 26 #define __twt(a,b) _twt(a,b) 27 #define TWT(a) __twt(a,TW_SUFFIX) 30 #define __tw(a,b) _tw(a,b) 31 #define TW(a) __tw(a,TW_SUFFIX) 114 #if (TW_TIMER_WHEELS != 1 && TW_TIMER_WHEELS != 2 && TW_TIMER_WHEELS != 3) 115 #error TW_TIMER_WHEELS must be 1, 2 or 3 128 #if (TW_TIMER_WHEELS == 3) 130 u16 fast_ring_offset;
132 u16 slow_ring_offset;
134 #if (TW_TIMER_WHEELS == 2) 136 u16 fast_ring_offset;
142 #if (TW_OVERFLOW_VECTOR > 0) 155 #ifndef __defined_tw_timer_wheel_slot__ 156 #define __defined_tw_timer_wheel_slot__ 209 #if TW_OVERFLOW_VECTOR > 0 213 #if TW_FAST_WHEEL_BITMAP > 0 215 uword *fast_slot_bitmap;
219 void (*expired_timer_callback) (
u32 * expired_timer_handles);
228 #if TW_START_STOP_TRACE_SIZE > 0 232 TWT (
trace) traces[TW_START_STOP_TRACE_SIZE];
235 }
TWT (tw_timer_wheel);
238 u32 pool_index,
u32 timer_id,
u64 interval);
246 void *expired_timer_callback,
247 f64 timer_interval,
u32 max_expirations);
254 #if TW_FAST_WHEEL_BITMAP 255 u32 TW (tw_timer_first_expires_in_ticks) (
TWT (tw_timer_wheel) * tw);
258 #if TW_START_STOP_TRACE_SIZE > 0 259 void TW (tw_search_trace) (
TWT (tw_timer_wheel) * tw,
u32 handle);
260 void TW (tw_timer_trace) (
TWT (tw_timer_wheel) * tw,
u32 timer_id,
261 u32 pool_index,
u32 handle);
void TW() tw_timer_wheel_free(TWT(tw_timer_wheel)*tw)
Free a tw timer wheel template instance.
u64 current_tick
current tick
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
u8 pad[3]
log2 (size of the packing page block)
void TW() tw_timer_wheel_init(TWT(tw_timer_wheel)*tw, void *expired_timer_callback, f64 timer_interval, u32 max_expirations)
Initialize a tw timer wheel template instance.
u32 *TW() tw_timer_expire_timers_vec(TWT(tw_timer_wheel)*tw, f64 now, u32 *vec)
Fixed length block allocator.
typedef CLIB_PACKED(struct{u8 timer_id;u32 pool_index;u32 handle;}) TWT(trace)
u32 max_expirations
maximum expirations
f64 timer_interval
Timer interval, also needed to avoid fp divide in speed path.
u64 first_expires_tick
first expiration time
static timer_callback_t * timers
#define TW_SLOTS_PER_RING
void TW() tw_timer_update(TWT(tw_timer_wheel)*tw, u32 handle, u64 interval)
Update a tw timer.
u32 TW() tw_timer_start(TWT(tw_timer_wheel)*tw, u32 pool_index, u32 timer_id, u64 interval)
Start a Tw Timer.
void TW() tw_timer_stop(TWT(tw_timer_wheel)*tw, u32 handle)
Stop a tw timer.
f64 next_run_time
Next time the wheel should run.
u32 next
next, previous pool indices
u32 * expired_timer_handles
vectors of expired timers
Bitmaps built as vectors of machine words.
f64 ticks_per_second
Timer ticks per second.
u32 *TW() tw_timer_expire_timers(TWT(tw_timer_wheel)*tw, f64 now)
int TW() tw_timer_handle_is_free(TWT(tw_timer_wheel)*tw, u32 handle)
f64 last_run_time
Last time the wheel ran.
u32 user_handle
user timer handle
u32 head_index
Listhead of timers which expire in this interval.