From: Sebastian Wilhelmi Date: Thu, 30 Aug 2001 14:19:20 +0000 (+0000) Subject: Add 'want_to_read' to GStaticRWLock to avoid calling g_cond_broadcast, X-Git-Tag: GLIB_1_3_7~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd2329ae666d23952ff808ae8745a353a3c4e662;p=platform%2Fupstream%2Fglib.git Add 'want_to_read' to GStaticRWLock to avoid calling g_cond_broadcast, 2001-08-30 Sebastian Wilhelmi * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to GStaticRWLock to avoid calling g_cond_broadcast, when no one is waiting. --- diff --git a/ChangeLog b/ChangeLog index 78fe193..b6af46b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 78fe193..b6af46b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2001-08-30 Sebastian Wilhelmi + * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to + GStaticRWLock to avoid calling g_cond_broadcast, when no one is + waiting. + * glib/gmain.c (g_main_context_add_poll_unlocked): Don't free cached_poll_array, when adding new poll's. This is taken care for in g_main_context_iterate. diff --git a/glib/gthread.c b/glib/gthread.c index ea16bcd..96cb3f4 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -692,7 +692,7 @@ g_static_rw_lock_signal (GStaticRWLock* lock) { if (lock->want_to_write && lock->write_cond) g_cond_signal (lock->write_cond); - else if (lock->read_cond) + else if (lock->want_to_read && lock->read_cond) g_cond_broadcast (lock->read_cond); } @@ -705,8 +705,10 @@ g_static_rw_lock_reader_lock (GStaticRWLock* lock) return; g_static_mutex_lock (&lock->mutex); + lock->want_to_read++; while (lock->write || lock->want_to_write) g_static_rw_lock_wait (&lock->read_cond, &lock->mutex); + lock->want_to_read--; lock->read_counter++; g_static_mutex_unlock (&lock->mutex); } diff --git a/glib/gthread.h b/glib/gthread.h index 58043bf..215cc28 100644 --- a/glib/gthread.h +++ b/glib/gthread.h @@ -263,10 +263,11 @@ struct _GStaticRWLock GCond *write_cond; guint read_counter; gboolean write; + guint want_to_read; guint want_to_write; }; -#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, FALSE } +#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } void g_static_rw_lock_init (GStaticRWLock* lock); void g_static_rw_lock_reader_lock (GStaticRWLock* lock);