mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 12:55:48 +01:00
Add 'want_to_read' to GStaticRWLock to avoid calling g_cond_broadcast,
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib/gthread.h, glib/gthread.c: Add 'want_to_read' to GStaticRWLock to avoid calling g_cond_broadcast, when no one is waiting.
This commit is contained in:
parent
cf11b57917
commit
bd2329ae66
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-08-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* 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
|
* 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
|
cached_poll_array, when adding new poll's. This is taken care for
|
||||||
in g_main_context_iterate.
|
in g_main_context_iterate.
|
||||||
|
@ -692,7 +692,7 @@ g_static_rw_lock_signal (GStaticRWLock* lock)
|
|||||||
{
|
{
|
||||||
if (lock->want_to_write && lock->write_cond)
|
if (lock->want_to_write && lock->write_cond)
|
||||||
g_cond_signal (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);
|
g_cond_broadcast (lock->read_cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,8 +705,10 @@ g_static_rw_lock_reader_lock (GStaticRWLock* lock)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
g_static_mutex_lock (&lock->mutex);
|
g_static_mutex_lock (&lock->mutex);
|
||||||
|
lock->want_to_read++;
|
||||||
while (lock->write || lock->want_to_write)
|
while (lock->write || lock->want_to_write)
|
||||||
g_static_rw_lock_wait (&lock->read_cond, &lock->mutex);
|
g_static_rw_lock_wait (&lock->read_cond, &lock->mutex);
|
||||||
|
lock->want_to_read--;
|
||||||
lock->read_counter++;
|
lock->read_counter++;
|
||||||
g_static_mutex_unlock (&lock->mutex);
|
g_static_mutex_unlock (&lock->mutex);
|
||||||
}
|
}
|
||||||
|
@ -263,10 +263,11 @@ struct _GStaticRWLock
|
|||||||
GCond *write_cond;
|
GCond *write_cond;
|
||||||
guint read_counter;
|
guint read_counter;
|
||||||
gboolean write;
|
gboolean write;
|
||||||
|
guint want_to_read;
|
||||||
guint want_to_write;
|
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_init (GStaticRWLock* lock);
|
||||||
void g_static_rw_lock_reader_lock (GStaticRWLock* lock);
|
void g_static_rw_lock_reader_lock (GStaticRWLock* lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user