From 722bf4621703ef238fa81018f8c3e68bcef91354 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 18 Apr 2022 10:25:03 -0400 Subject: fixes #1574 Non-blocking version of nng_aio_wait / nng_aio_result This introduces a new API, nng_aio_busy(), that can be used to query the status of the aio without blocking. Some minor documentation fixes are included. --- src/core/taskq.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/core/taskq.c') diff --git a/src/core/taskq.c b/src/core/taskq.c index e06bc264..d914093b 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2022 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -31,12 +31,12 @@ static void nni_taskq_thread(void *self) { nni_taskq_thr *thr = self; - nni_taskq * tq = thr->tqt_tq; - nni_task * task; + nni_taskq *tq = thr->tqt_tq; + nni_task *task; - nni_thr_set_name(NULL, "nng:task"); + nni_thr_set_name(NULL, "nng:task"); - nni_mtx_lock(&tq->tq_mtx); + nni_mtx_lock(&tq->tq_mtx); for (;;) { if ((task = nni_list_first(&tq->tq_tasks)) != NULL) { @@ -207,6 +207,16 @@ nni_task_wait(nni_task *task) nni_mtx_unlock(&task->task_mtx); } +bool +nni_task_busy(nni_task *task) +{ + bool busy; + nni_mtx_lock(&task->task_mtx); + busy = task->task_busy; + nni_mtx_unlock(&task->task_mtx); + return (busy); +} + void nni_task_init(nni_task *task, nni_taskq *tq, nni_cb cb, void *arg) { -- cgit v1.2.3-70-g09d2