17 #error do not include tw_timer_template.h directly 24 #define _twt(a,b) a##b##_t 25 #define __twt(a,b) _twt(a,b) 26 #define TWT(a) __twt(a,TW_SUFFIX) 29 #define __tw(a,b) _tw(a,b) 30 #define TW(a) __tw(a,TW_SUFFIX) 113 #if (TW_TIMER_WHEELS != 1 && TW_TIMER_WHEELS != 2 && TW_TIMER_WHEELS != 3) 114 #error TW_TIMER_WHEELS must be 1, 2 or 3 127 #if (TW_TIMER_WHEELS == 3) 129 u16 fast_ring_offset;
131 u16 slow_ring_offset;
133 #if (TW_TIMER_WHEELS == 2) 135 u16 fast_ring_offset;
141 #if (TW_OVERFLOW_VECTOR > 0) 154 #ifndef __defined_tw_timer_wheel_slot__ 155 #define __defined_tw_timer_wheel_slot__ 201 #if TW_OVERFLOW_VECTOR > 0 206 void (*expired_timer_callback) (
u32 * expired_timer_handles);
213 }
TWT (tw_timer_wheel);
216 u32 pool_index,
u32 timer_id,
u64 interval);
221 void *expired_timer_callback,
222 f64 timer_interval,
u32 max_expirations);
void TW() tw_timer_wheel_free(TWT(tw_timer_wheel)*tw)
Free a tw timer wheel template instance.
u64 current_tick
current tick
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.
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
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
vector of expired timers
f64 ticks_per_second
Timer ticks per second.
u32 *TW() tw_timer_expire_timers(TWT(tw_timer_wheel)*tw, f64 now)
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.