summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/wheel.c21
-rw-r--r--lib/wheel.h4
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/wheel.c b/lib/wheel.c
index b1a3e89fc7..722b02424a 100644
--- a/lib/wheel.c
+++ b/lib/wheel.c
@@ -29,7 +29,9 @@ DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List")
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;
@@ -65,15 +67,29 @@ static int wheel_timer_thread(struct thread *t)
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 *))
+ 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;
@@ -104,6 +120,7 @@ void wheel_delete(struct timer_wheel *wheel)
THREAD_OFF(wheel->timer);
XFREE(MTYPE_TIMER_WHEEL_LIST, wheel->wheel_slot_lists);
+ XFREE(MTYPE_TIMER_WHEEL, wheel->name);
XFREE(MTYPE_TIMER_WHEEL, wheel);
}
diff --git a/lib/wheel.h b/lib/wheel.h
index 1f9f95ed31..c8e83fafcb 100644
--- a/lib/wheel.h
+++ b/lib/wheel.h
@@ -21,6 +21,7 @@
#define __WHEEL_H__
struct timer_wheel {
+ char *name;
struct thread_master *master;
int slots;
long long curr_slot;
@@ -76,7 +77,8 @@ struct timer_wheel {
*/
struct timer_wheel *wheel_init(struct thread_master *master, int period,
size_t slots, unsigned int (*slot_key)(void *),
- void (*slot_run)(void *));
+ void (*slot_run)(void *),
+ const char *run_name);
/*
* Delete the specified timer wheel created