summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2023-04-27 15:48:07 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2023-04-27 15:48:07 +0100
commit7adca698d89461968b0cca807b863a3b7837e2c6 (patch)
tree0c39f6d18aca3483a4300a6970779ef1dddf5863
parent7922d3200cabd4c6ddb85e020b68698bbcc85ffd (diff)
downloadglib-7adca698d89461968b0cca807b863a3b7837e2c6.tar.gz
gthreadpool: Clarify that item_free_func is not normally called
If you’re only quickly looking at the API signature, it looks like `item_free_func` will be called for all items enqueued to the thread pool. As it happens, it’s actually only called for the items which are still enqueued when the thread pool is destroyed. The user’s `GFunc` is responsible for freeing items which are successfully dequeued and processed during the lifetime of the thread pool. That’s a bit of a gotcha, so document it more explicitly. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--glib/gthreadpool.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/glib/gthreadpool.c b/glib/gthreadpool.c
index 3151cb6ad..54e49b3c0 100644
--- a/glib/gthreadpool.c
+++ b/glib/gthreadpool.c
@@ -576,6 +576,9 @@ g_thread_pool_new (GFunc func,
* to g_thread_pool_push() in the case that the #GThreadPool is stopped
* and freed before all tasks have been executed.
*
+ * @item_free_func will *not* be called on items successfully passed to @func.
+ * @func is responsible for freeing the items passed to it.
+ *
* Returns: (transfer full): the new #GThreadPool
*
* Since: 2.70