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>
This commit is contained in:
Philip Withnall 2023-04-27 15:48:07 +01:00
parent 7922d3200c
commit 7adca698d8

View File

@ -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