mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gthreadpool: Remove a dummy item from the queue before freeing
Now that `g_thread_pool_new_full()` can be used to set a user-provided free function for queue elements, ensure that the internal dummy item used to wake up the worker threads is removed from the queue before it’s called. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2456
This commit is contained in:
parent
51b0cd3ccc
commit
b402f66c07
@ -964,6 +964,11 @@ g_thread_pool_free_internal (GRealThreadPool* pool)
|
||||
g_return_if_fail (pool->running == FALSE);
|
||||
g_return_if_fail (pool->num_threads == 0);
|
||||
|
||||
/* Ensure the dummy item pushed on by g_thread_pool_wakeup_and_stop_all() is
|
||||
* removed, before it’s potentially passed to the user-provided
|
||||
* @item_free_func. */
|
||||
g_async_queue_remove (pool->queue, GUINT_TO_POINTER (1));
|
||||
|
||||
g_async_queue_unref (pool->queue);
|
||||
g_cond_clear (&pool->cond);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user