aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-26 08:29:16 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-26 08:29:18 -0800
commitd6ed8c84ea066c8a6b27dc052425e042ea06b738 (patch)
tree801f74da92278503c95c90427302aeaf75f43244 /src/core
parent7ec45b840662b81e87bf04b51c9bb6c5b43b3929 (diff)
downloadnng-d6ed8c84ea066c8a6b27dc052425e042ea06b738.tar.gz
nng-d6ed8c84ea066c8a6b27dc052425e042ea06b738.tar.bz2
nng-d6ed8c84ea066c8a6b27dc052425e042ea06b738.zip
taskq: skip the lock/unlock if there is no callback
This should help some cases of synchronous callers that don't use a callback at all.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/taskq.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/taskq.c b/src/core/taskq.c
index 53252a8e..6b089767 100644
--- a/src/core/taskq.c
+++ b/src/core/taskq.c
@@ -150,13 +150,13 @@ nni_task_exec(nni_task *task)
} else {
task->task_busy++;
}
- nni_mtx_unlock(&task->task_mtx);
if (task->task_cb != NULL) {
+ nni_mtx_unlock(&task->task_mtx);
task->task_cb(task->task_arg);
+ nni_mtx_lock(&task->task_mtx);
}
- nni_mtx_lock(&task->task_mtx);
task->task_busy--;
if (task->task_busy == 0) {
nni_cv_wake(&task->task_cv);