- {
- /* No task was received, so this thread goes to the global
- * pool.
- */
- gboolean free_pool = FALSE;
-
- DEBUG_MSG (("thread %p leaving pool %p for global pool.",
- g_thread_self (), pool));
- pool->num_threads--;
-
- if (!pool->running)
- {
- if (!pool->waiting)
- {
- if (pool->num_threads == 0)
- {
- /* If the pool is not running and no other
- * thread is waiting for this thread pool to
- * finish and this is the last thread of this
- * pool, free the pool.
- */
- free_pool = TRUE;
- }
- else
- {
- /* If the pool is not running and no other
- * thread is waiting for this thread pool to
- * finish and this is not the last thread of
- * this pool and there are no tasks left in the
- * queue, wakeup the remaining threads.
- */
- if (g_async_queue_length_unlocked (pool->queue) ==
- - pool->num_threads)
- g_thread_pool_wakeup_and_stop_all (pool);
- }
- }
- else if (pool->immediate ||
- g_async_queue_length_unlocked (pool->queue) <= 0)
- {
- /* If the pool is not running and another thread is
- * waiting for this thread pool to finish and there
- * are either no tasks left or the pool shall stop
- * immediatly, inform the waiting thread of a change
- * of the thread pool state.
- */
- g_cond_broadcast (pool->cond);
- }
- }
-
- g_async_queue_unlock (pool->queue);
-
- if (free_pool)
- g_thread_pool_free_internal (pool);
-
- if ((pool = g_thread_pool_wait_for_new_pool ()) == NULL)
- break;
-
- g_async_queue_lock (pool->queue);
-
- DEBUG_MSG (("thread %p entering pool %p from global pool.",
- g_thread_self (), pool));
-
- /* pool->num_threads++ is not done here, but in
- * g_thread_pool_start_thread to make the new started thread
- * known to the pool, before itself can do it.
- */
- }
+ {
+ /* No task was received, so this thread goes to the global pool. */
+ gboolean free_pool = FALSE;
+
+ DEBUG_MSG (("thread %p leaving pool %p for global pool.",
+ g_thread_self (), pool));
+ pool->num_threads--;
+
+ if (!pool->running)
+ {
+ if (!pool->waiting)
+ {
+ if (pool->num_threads == 0)
+ {
+ /* If the pool is not running and no other
+ * thread is waiting for this thread pool to
+ * finish and this is the last thread of this
+ * pool, free the pool.
+ */
+ free_pool = TRUE;
+ }
+ else
+ {
+ /* If the pool is not running and no other
+ * thread is waiting for this thread pool to
+ * finish and this is not the last thread of
+ * this pool and there are no tasks left in the
+ * queue, wakeup the remaining threads.
+ */
+ if (g_async_queue_length_unlocked (pool->queue) ==
+ - pool->num_threads)
+ g_thread_pool_wakeup_and_stop_all (pool);
+ }
+ }
+ else if (pool->immediate ||
+ g_async_queue_length_unlocked (pool->queue) <= 0)
+ {
+ /* If the pool is not running and another thread is
+ * waiting for this thread pool to finish and there
+ * are either no tasks left or the pool shall stop
+ * immediately, inform the waiting thread of a change
+ * of the thread pool state.
+ */
+ g_cond_broadcast (&pool->cond);
+ }
+ }
+
+ g_async_queue_unlock (pool->queue);
+
+ if (free_pool)
+ g_thread_pool_free_internal (pool);
+
+ if ((pool = g_thread_pool_wait_for_new_pool ()) == NULL)
+ break;
+
+ g_async_queue_lock (pool->queue);
+
+ DEBUG_MSG (("thread %p entering pool %p from global pool.",
+ g_thread_self (), pool));
+
+ /* pool->num_threads++ is not done here, but in
+ * g_thread_pool_start_thread to make the new started
+ * thread known to the pool before itself can do it.
+ */
+ }