[glib] GAsyncQueue: simplify an internal function
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GAsyncQueue: simplify an internal function
- Date: Sun, 2 Oct 2011 00:23:52 +0000 (UTC)
commit 3d814e7a2ae80f422889c5f830af7e26c1f88a02
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 1 20:16:32 2011 -0400
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().
glib/gasyncqueue.c | 27 +++++++--------------------
1 files changed, 7 insertions(+), 20 deletions(-)
---
diff --git a/glib/gasyncqueue.c b/glib/gasyncqueue.c
index c373fe9..f80fca5 100644
--- a/glib/gasyncqueue.c
+++ b/glib/gasyncqueue.c
@@ -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))
- g_cond_wait (&queue->cond, &queue->mutex);
- queue->waiting_threads--;
- }
- else
+ queue->waiting_threads++;
+ while (!g_queue_peek_tail_link (&queue->queue))
{
- 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]