* and the list of poll records
*/
GMutex mutex;
- GCond *cond;
+ GCond cond;
GThread *owner;
guint owner_count;
GSList *waiters;
poll_rec_list_free (context, context->poll_records);
g_wakeup_free (context->wakeup);
-
- if (context->cond != NULL)
- g_cond_free (context->cond);
+ g_cond_clear (&context->cond);
g_free (context);
}
context = g_new0 (GMainContext, 1);
g_mutex_init (&context->mutex);
+ g_cond_init (&context->cond);
context->owner = NULL;
context->waiters = NULL;
if (!block)
return FALSE;
- if (!context->cond)
- context->cond = g_cond_new ();
-
got_ownership = g_main_context_wait (context,
- context->cond,
- &context->mutex);
+ &context->cond,
+ &context->mutex);
if (!got_ownership)
return FALSE;
if (!loop->is_running)
loop->is_running = TRUE;
- if (!loop->context->cond)
- loop->context->cond = g_cond_new ();
-
while (loop->is_running && !got_ownership)
got_ownership = g_main_context_wait (loop->context,
- loop->context->cond,
- &loop->context->mutex);
+ &loop->context->cond,
+ &loop->context->mutex);
if (!loop->is_running)
{
loop->is_running = FALSE;
g_wakeup_signal (loop->context->wakeup);
- if (loop->context->cond)
- g_cond_broadcast (loop->context->cond);
+ g_cond_broadcast (&loop->context->cond);
UNLOCK_CONTEXT (loop->context);
}
{
GThreadPool pool;
GAsyncQueue *queue;
- GCond *cond;
+ GCond cond;
gint max_threads;
gint num_threads;
gboolean running;
* immediately, inform the waiting thread of a change
* of the thread pool state.
*/
- g_cond_broadcast (pool->cond);
+ g_cond_broadcast (&pool->cond);
}
}
retval->pool.user_data = user_data;
retval->pool.exclusive = exclusive;
retval->queue = g_async_queue_new ();
- retval->cond = NULL;
+ g_cond_init (&retval->cond);
retval->max_threads = max_threads;
retval->num_threads = 0;
retval->running = TRUE;
if (wait_)
{
- real->cond = g_cond_new ();
-
while (g_async_queue_length_unlocked (real->queue) != -real->num_threads &&
!(immediate && real->num_threads == 0))
- g_cond_wait (real->cond, _g_async_queue_get_mutex (real->queue));
+ g_cond_wait (&real->cond, _g_async_queue_get_mutex (real->queue));
}
if (immediate || g_async_queue_length_unlocked (real->queue) == -real->num_threads)
g_return_if_fail (pool->num_threads == 0);
g_async_queue_unref (pool->queue);
-
- if (pool->cond)
- g_cond_free (pool->cond);
+ g_cond_clear (&pool->cond);
g_free (pool);
}