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__ 183 TWT (tw_timer) * timers;
206 #if TW_OVERFLOW_VECTOR > 0 210 #if TW_FAST_WHEEL_BITMAP > 0 212 uword *fast_slot_bitmap;
216 void (*expired_timer_callback) (
u32 * expired_timer_handles);
225 #if TW_START_STOP_TRACE_SIZE > 0 229 TWT (
trace) traces[TW_START_STOP_TRACE_SIZE];
232 }
TWT (tw_timer_wheel);
235 u32 pool_index,
u32 timer_id,
u64 interval);
243 void *expired_timer_callback,
244 f64 timer_interval,
u32 max_expirations);
251 #if TW_FAST_WHEEL_BITMAP 252 u32 TW (tw_timer_first_expires_in_ticks) (
TWT (tw_timer_wheel) * tw);
255 #if TW_START_STOP_TRACE_SIZE > 0 256 void TW (tw_search_trace) (
TWT (tw_timer_wheel) * tw,
u32 handle);
257 void TW (tw_timer_trace) (
TWT (tw_timer_wheel) * tw,
u32 timer_id,
258 u32 pool_index,
u32 handle);
u32 TW() tw_timer_start(TWT(tw_timer_wheel) *tw, u32 pool_index, u32 timer_id, u64 interval)
Start a Tw Timer.
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)
typedef CLIB_PACKED(struct { u8 timer_id;u32 pool_index;u32 handle;}) TWT(trace)
void TW() tw_timer_stop(TWT(tw_timer_wheel) *tw, u32 handle)
Stop a tw timer.
Fixed length block allocator.
u32 max_expirations
maximum expirations
f64 timer_interval
Timer interval, also needed to avoid fp divide in speed path.
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)
#define TW_SLOTS_PER_RING
void TW() tw_timer_update(TWT(tw_timer_wheel) *tw, u32 handle, u64 interval)
Update 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
u32 *TW() tw_timer_expire_timers_vec(TWT(tw_timer_wheel) *tw, f64 now, u32 *vec)
Bitmaps built as vectors of machine words.
f64 ticks_per_second
Timer ticks per second.
void TW() tw_timer_wheel_free(TWT(tw_timer_wheel) *tw)
Free a tw timer wheel template instance.
f64 last_run_time
Last time the wheel ran.
u32 user_handle
user timer handle
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 head_index
Listhead of timers which expire in this interval.