diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-11-29 19:36:26 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-09-13 10:51:13 -0400 |
| commit | c2cfa843b42d30b8d589d507e5b41f6fac704384 (patch) | |
| tree | 98e30c211a1d02c86059afc44fe5e8d06d4c6392 /lib/wheel.c | |
| parent | b7fb24ce6f9b53d70c3cb8f00ea1f85ea0ea905c (diff) | |
lib, pimd: Convert timer_wheel to use thread_execute_name
Allow at timer wheel creation time the ability to specify a
name for what we want the 'show thread cpu' to show up as.
Modify pim to note this.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/wheel.c')
| -rw-r--r-- | lib/wheel.c | 21 |
1 files changed, 19 insertions, 2 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); } |
