summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/os/taskq.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/os/taskq.c')
-rw-r--r--usr/src/uts/common/os/taskq.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/usr/src/uts/common/os/taskq.c b/usr/src/uts/common/os/taskq.c
index 814b738581..7a38181cf7 100644
--- a/usr/src/uts/common/os/taskq.c
+++ b/usr/src/uts/common/os/taskq.c
@@ -26,6 +26,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2017, Joyent, Inc.
*/
/*
@@ -1320,6 +1321,22 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags,
}
/*
+ * Allow our caller to ask if there are tasks pending on the queue.
+ */
+boolean_t
+taskq_empty(taskq_t *tq)
+{
+ boolean_t rv;
+
+ ASSERT3P(tq, !=, curthread->t_taskq);
+ mutex_enter(&tq->tq_lock);
+ rv = (tq->tq_task.tqent_next == &tq->tq_task) && (tq->tq_active == 0);
+ mutex_exit(&tq->tq_lock);
+
+ return (rv);
+}
+
+/*
* Wait for all pending tasks to complete.
* Calling taskq_wait from a task will cause deadlock.
*/