mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-05 08:56:16 +01:00
GAsyncQueue: simplify an internal function
g_cond_timed_wait() behaves like g_cond_wait() when given NULL, so no need have different branches for that in g_async_queue_pop_intern_unlocked().
This commit is contained in:
parent
8c5400ff45
commit
3d814e7a2a
@ -409,33 +409,20 @@ g_async_queue_pop_intern_unlocked (GAsyncQueue *queue,
|
||||
{
|
||||
gpointer retval;
|
||||
|
||||
if (!g_queue_peek_tail_link (&queue->queue))
|
||||
if (!g_queue_peek_tail_link (&queue->queue) && wait)
|
||||
{
|
||||
if (!wait)
|
||||
return NULL;
|
||||
|
||||
if (!end_time)
|
||||
queue->waiting_threads++;
|
||||
while (!g_queue_peek_tail_link (&queue->queue))
|
||||
{
|
||||
queue->waiting_threads++;
|
||||
while (!g_queue_peek_tail_link (&queue->queue))
|
||||
g_cond_wait (&queue->cond, &queue->mutex);
|
||||
queue->waiting_threads--;
|
||||
}
|
||||
else
|
||||
{
|
||||
queue->waiting_threads++;
|
||||
while (!g_queue_peek_tail_link (&queue->queue))
|
||||
if (!g_cond_timed_wait (&queue->cond, &queue->mutex, end_time))
|
||||
break;
|
||||
queue->waiting_threads--;
|
||||
if (!g_queue_peek_tail_link (&queue->queue))
|
||||
return NULL;
|
||||
if (!g_cond_timed_wait (&queue->cond, &queue->mutex, end_time))
|
||||
break;
|
||||
}
|
||||
queue->waiting_threads--;
|
||||
}
|
||||
|
||||
retval = g_queue_pop_tail (&queue->queue);
|
||||
|
||||
g_assert (retval);
|
||||
g_assert (retval || !wait || end_time);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user