mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +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;
|
gpointer retval;
|
||||||
|
|
||||||
if (!g_queue_peek_tail_link (&queue->queue))
|
if (!g_queue_peek_tail_link (&queue->queue) && wait)
|
||||||
{
|
{
|
||||||
if (!wait)
|
queue->waiting_threads++;
|
||||||
return NULL;
|
while (!g_queue_peek_tail_link (&queue->queue))
|
||||||
|
|
||||||
if (!end_time)
|
|
||||||
{
|
{
|
||||||
queue->waiting_threads++;
|
if (!g_cond_timed_wait (&queue->cond, &queue->mutex, end_time))
|
||||||
while (!g_queue_peek_tail_link (&queue->queue))
|
break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
queue->waiting_threads--;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = g_queue_pop_tail (&queue->queue);
|
retval = g_queue_pop_tail (&queue->queue);
|
||||||
|
|
||||||
g_assert (retval);
|
g_assert (retval || !wait || end_time);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user