summaryrefslogtreecommitdiff
path: root/lib/workqueue.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2022-06-08 10:21:35 -0400
committerDonald Sharp <sharpd@nvidia.com>2022-06-08 11:38:22 -0400
commitd1c276681fbe7200cf43f03dd4638b2fc872b04d (patch)
treed615d21db387b2a2f0eeb6f992da8719521b960a /lib/workqueue.c
parent71623b304e78f987b7d730e431f79324c787a2dd (diff)
lib: Fixup workqueue.c to use proper thread.h semantics
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/workqueue.c')
-rw-r--r--lib/workqueue.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 92869594dd..c703de90b3 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -103,8 +103,7 @@ void work_queue_free_and_null(struct work_queue **wqp)
{
struct work_queue *wq = *wqp;
- if (wq->thread != NULL)
- thread_cancel(&(wq->thread));
+ THREAD_OFF(wq->thread);
while (!work_queue_empty(wq)) {
struct work_queue_item *item = work_queue_last_item(wq);
@@ -122,16 +121,14 @@ void work_queue_free_and_null(struct work_queue **wqp)
bool work_queue_is_scheduled(struct work_queue *wq)
{
- return (wq->thread != NULL);
+ return thread_is_scheduled(wq->thread);
}
static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
{
/* if appropriate, schedule work queue thread */
- if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL)
- && !work_queue_empty(wq)) {
- wq->thread = NULL;
-
+ if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) &&
+ !thread_is_scheduled(wq->thread) && !work_queue_empty(wq)) {
/* Schedule timer if there's a delay, otherwise just schedule
* as an 'event'
*/
@@ -144,7 +141,8 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
&wq->thread);
/* set thread yield time, if needed */
- if (wq->thread && wq->spec.yield != THREAD_YIELD_TIME_SLOT)
+ if (thread_is_scheduled(wq->thread) &&
+ wq->spec.yield != THREAD_YIELD_TIME_SLOT)
thread_set_yield_time(wq->thread, wq->spec.yield);
return 1;
} else
@@ -215,10 +213,7 @@ void workqueue_cmd_init(void)
*/
void work_queue_plug(struct work_queue *wq)
{
- if (wq->thread)
- thread_cancel(&(wq->thread));
-
- wq->thread = NULL;
+ THREAD_OFF(wq->thread);
UNSET_FLAG(wq->flags, WQ_UNPLUGGED);
}
@@ -250,8 +245,6 @@ void work_queue_run(struct thread *thread)
assert(wq);
- wq->thread = NULL;
-
/* calculate cycle granularity:
* list iteration == 1 run
* listnode processing == 1 cycle