access datalist flags via atomic pointer access funcitons, instead of

Wed Nov 23 17:34:01 2005  Tim Janik  <timj@imendio.com>

        * glib/gdataset.c: access datalist flags via atomic pointer access
        funcitons, instead of acquiring the dataset lock. this is faster and
        also matches the atomic pointer readouts in gdatalistprivate.h and
        direct pointer modifications required by gobject.c.
This commit is contained in:
Tim Janik 2005-11-23 17:54:57 +00:00 committed by Tim Janik
parent 6e5f465924
commit 2027d87b5b
4 changed files with 38 additions and 9 deletions

View File

@ -1,3 +1,10 @@
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access
funcitons, instead of acquiring the dataset lock. this is faster and
also matches the atomic pointer readouts in gdatalistprivate.h and
direct pointer modifications required by gobject.c.
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: streamlined initialization code somewhat,

View File

@ -1,3 +1,10 @@
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access
funcitons, instead of acquiring the dataset lock. this is faster and
also matches the atomic pointer readouts in gdatalistprivate.h and
direct pointer modifications required by gobject.c.
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: streamlined initialization code somewhat,

View File

@ -1,3 +1,10 @@
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access
funcitons, instead of acquiring the dataset lock. this is faster and
also matches the atomic pointer readouts in gdatalistprivate.h and
direct pointer modifications required by gobject.c.
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: streamlined initialization code somewhat,

View File

@ -525,12 +525,16 @@ void
g_datalist_set_flags (GData **datalist,
guint flags)
{
gpointer oldvalue;
g_return_if_fail (datalist != NULL);
g_return_if_fail ((flags & ~G_DATALIST_FLAGS_MASK) == 0);
G_LOCK (g_dataset_global);
*datalist = (GData*) (flags | (gsize) *datalist);
G_UNLOCK (g_dataset_global);
do
{
oldvalue = g_atomic_pointer_get (datalist);
}
while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, oldvalue,
(gpointer) ((gsize) oldvalue | flags)));
}
/**
@ -548,12 +552,16 @@ void
g_datalist_unset_flags (GData **datalist,
guint flags)
{
gpointer oldvalue;
g_return_if_fail (datalist != NULL);
g_return_if_fail ((flags & ~G_DATALIST_FLAGS_MASK) == 0);
G_LOCK (g_dataset_global);
*datalist = (GData*) (~(gsize) flags & (gsize) *datalist);
G_UNLOCK (g_dataset_global);
do
{
oldvalue = g_atomic_pointer_get (datalist);
}
while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, oldvalue,
(gpointer) ((gsize) oldvalue & ~(gsize) flags)));
}
/**
@ -569,7 +577,7 @@ guint
g_datalist_get_flags (GData **datalist)
{
g_return_val_if_fail (datalist != NULL, 0);
return G_DATALIST_GET_FLAGS (datalist); /* atomic macro */
}