*: Convert thread_should_yield and thread_set_yield_time

Convert thread_should_yield and thread_set_yield_time
to event_should_yield and event_set_yield_time

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-12-11 10:39:12 -05:00
parent 4f830a0799
commit 70c35c11f2
6 changed files with 10 additions and 10 deletions

View File

@ -1910,7 +1910,7 @@ unsigned long thread_consumed_time(RUSAGE_T *now, RUSAGE_T *start,
for CPU time. On balance, wall clock time seems to make sense. for CPU time. On balance, wall clock time seems to make sense.
Plus it has the added benefit that gettimeofday should be faster Plus it has the added benefit that gettimeofday should be faster
than calling getrusage. */ than calling getrusage. */
int thread_should_yield(struct event *thread) int event_should_yield(struct event *thread)
{ {
int result; int result;
frr_with_mutex (&thread->mtx) { frr_with_mutex (&thread->mtx) {
@ -1920,7 +1920,7 @@ int thread_should_yield(struct event *thread)
return result; return result;
} }
void thread_set_yield_time(struct event *thread, unsigned long yield_time) void event_set_yield_time(struct event *thread, unsigned long yield_time)
{ {
frr_with_mutex (&thread->mtx) { frr_with_mutex (&thread->mtx) {
thread->yield = yield_time; thread->yield = yield_time;

View File

@ -254,9 +254,9 @@ extern void event_call(struct event *event);
extern unsigned long event_timer_remain_second(struct event *event); extern unsigned long event_timer_remain_second(struct event *event);
extern struct timeval event_timer_remain(struct event *event); extern struct timeval event_timer_remain(struct event *event);
extern unsigned long event_timer_remain_msec(struct event *event); extern unsigned long event_timer_remain_msec(struct event *event);
extern int thread_should_yield(struct event *event); extern int event_should_yield(struct event *event);
/* set yield time for thread */ /* set yield time for thread */
extern void thread_set_yield_time(struct event *event, unsigned long); extern void event_set_yield_time(struct event *event, unsigned long);
/* Internal libfrr exports */ /* Internal libfrr exports */
extern void thread_getrusage(RUSAGE_T *); extern void thread_getrusage(RUSAGE_T *);

View File

@ -128,7 +128,7 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
/* set thread yield time, if needed */ /* set thread yield time, if needed */
if (thread_is_scheduled(wq->thread) && if (thread_is_scheduled(wq->thread) &&
wq->spec.yield != EVENT_YIELD_TIME_SLOT) wq->spec.yield != EVENT_YIELD_TIME_SLOT)
thread_set_yield_time(wq->thread, wq->spec.yield); event_set_yield_time(wq->thread, wq->spec.yield);
return 1; return 1;
} else } else
return 0; return 0;
@ -311,8 +311,8 @@ void work_queue_run(struct event *thread)
cycles++; cycles++;
/* test if we should yield */ /* test if we should yield */
if (!(cycles % wq->cycles.granularity) if (!(cycles % wq->cycles.granularity) &&
&& thread_should_yield(thread)) { event_should_yield(thread)) {
yielded = 1; yielded = 1;
goto stats; goto stats;
} }

View File

@ -3074,7 +3074,7 @@ void ospf_maxage_lsa_remover(struct event *thread)
} }
/* TODO: maybe convert this function to a work-queue */ /* TODO: maybe convert this function to a work-queue */
if (thread_should_yield(thread)) { if (event_should_yield(thread)) {
OSPF_TIMER_ON(ospf->t_maxage, OSPF_TIMER_ON(ospf->t_maxage,
ospf_maxage_lsa_remover, 0); ospf_maxage_lsa_remover, 0);
route_unlock_node( route_unlock_node(

View File

@ -67,7 +67,7 @@ static void clear_something(struct event *thread)
while (ws->i < ITERS_MAX) { while (ws->i < ITERS_MAX) {
slow_func(ws->vty, ws->str, ws->i); slow_func(ws->vty, ws->str, ws->i);
ws->i++; ws->i++;
if (thread_should_yield(thread)) { if (event_should_yield(thread)) {
event_add_timer_msec(master, clear_something, ws, 0, event_add_timer_msec(master, clear_something, ws, 0,
NULL); NULL);
return; return;

View File

@ -285,7 +285,7 @@ union g_addr ipv4ll_gateway;
*/ */
static inline int zfpm_thread_should_yield(struct event *t) static inline int zfpm_thread_should_yield(struct event *t)
{ {
return thread_should_yield(t); return event_should_yield(t);
} }
/* /*