From 7adca698d89461968b0cca807b863a3b7837e2c6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 27 Apr 2023 15:48:07 +0100 Subject: [PATCH] gthreadpool: Clarify that item_free_func is not normally called MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- glib/gthreadpool.c | 3 +++ 1 file changed, 3 insertions(+) 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