static int debug_timer_wheel = 0;
-static int wheel_timer_thread(struct thread *t)
+static int wheel_timer_thread(struct thread *t);
+
+static int wheel_timer_thread_helper(struct thread *t)
{
struct listnode *node, *nextnode;
unsigned long long curr_slot;
return 0;
}
+static int wheel_timer_thread(struct thread *t)
+{
+ struct timer_wheel *wheel;
+
+ wheel = THREAD_ARG(t);
+
+ thread_execute_name(wheel->master, wheel_timer_thread_helper,
+ wheel, 0, wheel->name);
+
+ return 0;
+}
+
struct timer_wheel *wheel_init(struct thread_master *master, int period,
- size_t slots, unsigned int (*slot_key)(void *),
- void (*slot_run)(void *))
+ size_t slots, unsigned int (*slot_key)(const void *),
+ void (*slot_run)(void *),
+ const char *run_name)
{
struct timer_wheel *wheel;
size_t i;
wheel = XCALLOC(MTYPE_TIMER_WHEEL, sizeof(struct timer_wheel));
+ wheel->name = XSTRDUP(MTYPE_TIMER_WHEEL, run_name);
wheel->slot_key = slot_key;
wheel->slot_run = slot_run;
int i;
for (i = 0; i < wheel->slots; i++) {
- list_delete_and_null(&wheel->wheel_slot_lists[i]);
+ list_delete(&wheel->wheel_slot_lists[i]);
}
THREAD_OFF(wheel->timer);
XFREE(MTYPE_TIMER_WHEEL_LIST, wheel->wheel_slot_lists);
+ XFREE(MTYPE_TIMER_WHEEL, wheel->name);
XFREE(MTYPE_TIMER_WHEEL, wheel);
}