summaryrefslogtreecommitdiff
path: root/lib/pthreadpool/pthreadpool.h
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2018-06-22 00:49:33 +0200
committerStefan Metzmacher <metze@samba.org>2018-07-12 14:25:18 +0200
commit505d298e81570bb118a9b82e5166a8f11139750b (patch)
treed5c39eb756e430939e9c7cd728fd4aea354f52b3 /lib/pthreadpool/pthreadpool.h
parent76474a6fad43c791293f4fb30dc7c155619c5dec (diff)
downloadsamba-505d298e81570bb118a9b82e5166a8f11139750b.tar.gz
pthreadpool: add pthreadpool_max_threads() and pthreadpool_queued_jobs() helpers
These can be used to implement some kind of flow control in the caller. E.g. unless pthreadpool_queued_jobs() is lower than pthreadpool_max_threads() is good to prepare new jobs. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'lib/pthreadpool/pthreadpool.h')
-rw-r--r--lib/pthreadpool/pthreadpool.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/pthreadpool/pthreadpool.h b/lib/pthreadpool/pthreadpool.h
index defbe5a9f62..cb8baffebb1 100644
--- a/lib/pthreadpool/pthreadpool.h
+++ b/lib/pthreadpool/pthreadpool.h
@@ -51,6 +51,27 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
void *signal_fn_private_data);
/**
+ * @brief Get the max threads value of pthreadpool
+ *
+ * @note This can be 0 for strict sync processing.
+ *
+ * @param[in] pool The pool
+ * @return number of possible threads
+ */
+size_t pthreadpool_max_threads(struct pthreadpool *pool);
+
+/**
+ * @brief The number of queued jobs of pthreadpool
+ *
+ * This is the number of jobs added by pthreadpool_add_job(),
+ * which are not yet processed by a thread.
+ *
+ * @param[in] pool The pool
+ * @return The number of jobs
+ */
+size_t pthreadpool_queued_jobs(struct pthreadpool *pool);
+
+/**
* @brief Destroy a pthreadpool
*
* Destroy a pthreadpool. If jobs are submitted, but not yet active in