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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <glib.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <glib-object.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-05 16:08:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifdef G_OS_UNIX
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <unistd.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define G_TYPE_TEST                (my_test_get_type ())
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define MY_TEST(test)              (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define MY_IS_TEST(test)           (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define MY_TEST_CLASS(tclass)      (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define MY_IS_TEST_CLASS(tclass)   (G_TYPE_CHECK_CLASS_TYPE ((tclass), G_TYPE_TEST))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define MY_TEST_GET_CLASS(test)    (G_TYPE_INSTANCE_GET_CLASS ((test), G_TYPE_TEST, GTestClass))
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								typedef struct _GTest GTest;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								typedef struct _GTestClass GTestClass;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								struct _GTest
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GObject object;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gint value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								struct _GTestClass
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GObjectClass parent_class;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  void (*test_signal1) (GTest * test, gint an_int);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  void (*test_signal2) (GTest * test, gint an_int);
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  gchar * (*test_signal3) (GTest * test, gint an_int);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static GType my_test_get_type (void);
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 00:00:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static gboolean stopping;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* Element signals and args */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								enum
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  TEST_SIGNAL1,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  TEST_SIGNAL2,
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  TEST_SIGNAL3,
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  /* add more above */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  LAST_SIGNAL
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								enum
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ARG_0,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ARG_TEST_PROP
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static void my_test_class_init (GTestClass * klass);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void my_test_init (GTest * test);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void my_test_dispose (GObject * object);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void signal2_handler (GTest * test, gint anint);
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static gchar * signal3_handler (GTest * test, gint anint);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static void my_test_set_property (GObject * object, guint prop_id,
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const GValue * value, GParamSpec * pspec);
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static void my_test_get_property (GObject * object, guint prop_id,
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    GValue * value, GParamSpec * pspec);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static GObjectClass *parent_class = NULL;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static guint my_test_signals[LAST_SIGNAL] = { 0 };
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static GType
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_get_type (void)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  static GType test_type = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (!test_type) {
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-29 22:02:00 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const GTypeInfo test_info = {
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      sizeof (GTestClass),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL,
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      (GClassInitFunc) my_test_class_init,
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      sizeof (GTest),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      0,
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      (GInstanceInitFunc) my_test_init,
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    test_type = g_type_register_static (G_TYPE_OBJECT, "GTest",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        &test_info, 0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return test_type;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_class_init (GTestClass * klass)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GObjectClass *gobject_class;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gobject_class = (GObjectClass *) klass;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  parent_class = g_type_class_ref (G_TYPE_OBJECT);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  gobject_class->dispose = my_test_dispose;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gobject_class->set_property = my_test_set_property;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gobject_class->get_property = my_test_get_property;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  my_test_signals[TEST_SIGNAL1] =
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      g_signal_new ("test-signal1", G_TYPE_FROM_CLASS (klass),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GTestClass, test_signal1), NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  my_test_signals[TEST_SIGNAL2] =
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      g_signal_new ("test-signal2", G_TYPE_FROM_CLASS (klass),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GTestClass, test_signal2), NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  my_test_signals[TEST_SIGNAL3] =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      g_signal_new ("test-signal3", G_TYPE_FROM_CLASS (klass),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GTestClass, test_signal3), NULL,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      NULL, g_cclosure_marshal_generic, G_TYPE_STRING, 1, G_TYPE_INT);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TEST_PROP,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      g_param_spec_int ("test-prop", "Test Prop", "Test property",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          0, 1, 0, G_PARAM_READWRITE));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  klass->test_signal2 = signal2_handler;
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  klass->test_signal3 = signal3_handler;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_init (GTest * test)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_test_message ("init %p\n", test);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test->value = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_dispose (GObject * object)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GTest *test;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  test = MY_TEST (object);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_test_message ("dispose %p!\n", test);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  G_OBJECT_CLASS (parent_class)->dispose (object);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_set_property (GObject * object, guint prop_id,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      const GValue * value, GParamSpec * pspec)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GTest *test;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  test = MY_TEST (object);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  switch (prop_id) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    case ARG_TEST_PROP:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      test->value = g_value_get_int (value);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    default:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_get_property (GObject * object, guint prop_id,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      GValue * value, GParamSpec * pspec)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GTest *test;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  test = MY_TEST (object);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  switch (prop_id) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    case ARG_TEST_PROP:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      g_value_set_int (value, test->value);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    default:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_do_signal1 (GTest * test)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_signal_emit (G_OBJECT (test), my_test_signals[TEST_SIGNAL1], 0, 0);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								signal2_handler (GTest * test, gint anint)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_do_signal2 (GTest * test)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_signal_emit (G_OBJECT (test), my_test_signals[TEST_SIGNAL2], 0, 0);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static gchar *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								signal3_handler (GTest * test, gint anint)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return g_strdup ("test");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								my_test_do_signal3 (GTest * test)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gchar *res;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_signal_emit (G_OBJECT (test), my_test_signals[TEST_SIGNAL3], 0, 0, &res);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_assert (res);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_free (res);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								my_test_do_prop (GTest * test)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-11 17:03:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  test->value = (int) g_random_int ();
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_object_notify (G_OBJECT (test), "test-prop");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static gpointer
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								run_thread (GTest * test)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-01 21:47:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  gint i = 1;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 00:00:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  while (!g_atomic_int_get (&stopping)) {
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (TESTNUM == 1)
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      my_test_do_signal1 (test);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (TESTNUM == 2)
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      my_test_do_signal2 (test);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (TESTNUM == 3)
							 | 
						
					
						
							
								
									
										
										
										
											2007-11-20 15:00:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      my_test_do_prop (test);
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (TESTNUM == 4)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      my_test_do_signal3 (test);
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-01 21:47:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if ((i++ % 10000) == 0) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        g_thread_yield (); /* force context switch */
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return NULL;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								notify (GObject *object, GParamSpec *spec, gpointer user_data)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gint value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_object_get (object, "test-prop", &value, NULL);
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-31 14:17:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (TESTNUM != 3)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    g_assert_cmpint (value, ==, 0);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static void
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test_refcount_signals (void)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  gint i;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GTest *test1, *test2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  GArray *test_threads;
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-01 21:47:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const gint n_threads = 1;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test1 = g_object_new (G_TYPE_TEST, NULL);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test2 = g_object_new (G_TYPE_TEST, NULL);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2005-07-20 20:46:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_signal_connect (test1, "notify::test-prop", G_CALLBACK (notify), NULL);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_signal_connect (test1, "test-signal1", G_CALLBACK (notify), NULL);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_signal_connect (test1, "test-signal2", G_CALLBACK (notify), NULL);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  stopping = FALSE;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-01 21:47:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  for (i = 0; i < n_threads; i++) {
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    GThread *thread;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 18:34:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    thread = g_thread_new (NULL, (GThreadFunc) run_thread, test1);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    g_array_append_val (test_threads, thread);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 18:34:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    thread = g_thread_new (NULL, (GThreadFunc) run_thread, test2);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    g_array_append_val (test_threads, thread);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-02 06:55:38 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_usleep (5000000);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 00:00:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_atomic_int_set (&stopping, TRUE);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  /* Join all threads */
							 | 
						
					
						
							
								
									
										
										
										
											2005-08-01 21:47:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  for (i = 0; i < 2 * n_threads; i++) {
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    GThread *thread;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    thread = g_array_index (test_threads, GThread *, i);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    g_thread_join (thread);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  g_array_free (test_threads, TRUE);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_object_unref (test1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_object_unref (test2);
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								int
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								main (int argc, gchar *argv[])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_log_set_always_fatal (G_LOG_LEVEL_WARNING |
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          G_LOG_LEVEL_CRITICAL |
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          g_log_set_always_fatal (G_LOG_FATAL_MASK));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_test_init (&argc, &argv, NULL);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  g_test_add_func ("/gobject/refcount/signals", test_refcount_signals);
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-19 16:38:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 09:31:50 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return g_test_run ();
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |