Make refcounting threadsafe by using atomic operations. (#166020, Wim
authorMatthias Clasen <mclasen@redhat.com>
Fri, 15 Jul 2005 16:51:10 +0000 (16:51 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 15 Jul 2005 16:51:10 +0000 (16:51 +0000)
commit39ea11ce6b107bf3969a2f94807675b458a5a887
treeb06f87caa8052fd3a656168201eadba77cc133e8
parent58729b464b44595704c4e8e65869fd2228554ed5
Make refcounting threadsafe by using atomic operations. (#166020, Wim

2005-07-15  Matthias Clasen  <mclasen@redhat.com>

Make refcounting threadsafe by using atomic
operations.  (#166020, Wim Taymans)

* gobject.c: Use a recursive lock to protect the
notify queue.
(g_object_unref): Get rid of g_object_last_unref and
do the last unref handling in g_object_unref.
(g_object_ref, g_object_unref): Use atomic operations.

* gsignal.c (struct _HandlerMatch): Use a full integer
for the ref_count field.
(handler_ref, handler_unref_R): Use atomic operations.

* gparam.c (g_param_spec_ref, g_param_spec_unref):
Use atomic operations instead of a lock to make the
refcounting threadsafe.

* gclosure.c (g_closure_ref, g_closure_unref): Use atomic
operations. This is more complicated here, since the
refcount is stored in a bitfield, so we also have
to access all other bitfield members atomically.

* gsignal.c (handlers_find): Read the meta_marshal flag
of the closure atomically.

* tests/Makefile.am (SUBDIRS): Add tests/refcount

* configure.in: Add tests/refcount

* tests/refcount/properties.c: Test property changes
from multiple threads.

* tests/refcount/signals.c: Test signal emission from
multiple threads.

* tests/refcount/objects.c: Test refcounting from
multiple threads.

* tests/refcount/objects2.c:
* tests/refcount/properties2.c: Tests to measure the
overhead of threadsafe refcounting.

* glib/giochannel.c (g_io_channel_ref, g_io_channel_unref):
Use atomic operations to make refcounting
threadsafe.  (#166020, Wim Taymans)
18 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-8
configure.in
glib/giochannel.c
gobject/ChangeLog
gobject/gclosure.c
gobject/gobject.c
gobject/gparam.c
gobject/gsignal.c
tests/Makefile.am
tests/refcount/Makefile.am [new file with mode: 0644]
tests/refcount/objects.c [new file with mode: 0644]
tests/refcount/objects2.c [new file with mode: 0644]
tests/refcount/properties.c [new file with mode: 0644]
tests/refcount/properties2.c [new file with mode: 0644]
tests/refcount/signals.c [new file with mode: 0644]