{
GAsyncQueue* retval = g_new (GAsyncQueue, 1);
retval->mutex = g_mutex_new ();
- retval->cond = g_cond_new ();
+ retval->cond = NULL;
retval->queue = g_queue_new ();
retval->waiting_threads = 0;
retval->ref_count = 1;
{
g_return_if_fail (queue->waiting_threads == 0);
g_mutex_free (queue->mutex);
- g_cond_free (queue->cond);
+ if (queue->cond)
+ g_cond_free (queue->cond);
g_queue_free (queue->queue);
g_free (queue);
}
g_return_if_fail (data);
g_queue_push_head (queue->queue, data);
- g_cond_signal (queue->cond);
+ if (queue->waiting_threads > 0)
+ g_cond_signal (queue->cond);
}
static gpointer
{
if (try)
return NULL;
+
+ if (!queue->cond)
+ queue->cond = g_cond_new ();
+
if (!end_time)
{
queue->waiting_threads++;