Commit Graph

3 Commits

Author SHA1 Message Date
Tim Janik
78373b68b9 Fixed up internal 'g_test*' names.
* refcount/signals.c:
* refcount/objects.c:
* refcount/objects2.c:
* refcount/closures.c:
* refcount/properties.c:
* refcount/properties2.c: changed namespace prefix from g_test_* to my_test_*
to not clash with newly introduced g_test* API in glib.

svn path=/trunk/; revision=5875
2007-11-20 15:00:20 +00:00
Tim Janik
10a3867a6e test high contention on closure reference counts to trigger and catch
Mon Aug  1 23:33:47 2005  Tim Janik  <timj@imendio.com>

        * tests/refcount/closures.c: test high contention on closure
        reference counts to trigger and catch non-atomic updates.

        * tests/refcount/objects.c:
        * tests/refcount/objects2.c:
        * tests/refcount/properties.c:
        * tests/refcount/properties2.c:
        * tests/refcount/signals.c:
        fixed up test and threading fundamentals. variables accessed from all
        threads need to be volatile. context switches are enforced by using
        g_thread_yield(), not g_usleep(1) which may result in busy waits on
        some platforms. for testcode, always consider all warnings and
        critical messages fatal. issue the currently running program on
        stdout. improved progress indicators.

        * tests/refcount/properties.c:
        * tests/refcount/objects.c:
        don't overdo the number of testing threads to keep the testing machine
        usable, 2 threads can produce as much contention as 20 if executing the
        same code.

        * tests/refcount/signals.c: only start 1 thread per object. GObject
        doesn't provide mutually exclusive object access, but only mutually
        exclusive reference count modification.

        * tests/Makefile.am: added closures test.
2005-08-01 21:47:15 +00:00
Matthias Clasen
39ea11ce6b 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)
2005-07-15 16:51:10 +00:00