139
140
GThread *threads[3] = { NULL, };
140
141
/* pause newly created threads */
141
sync_mutex = g_mutex_new();
142
142
g_mutex_lock (sync_mutex);
143
143
/* create threads */
144
144
threads[0] = g_thread_create (tester_init_thread, (gpointer) my_tester0_get_type(), TRUE, NULL);
158
158
g_assert_cmpint (g_atomic_int_get (&mtsafe_call_counter), ==, unsafe_call_counter);
165
typedef GObjectClass PropTesterClass;
166
G_DEFINE_TYPE (PropTester, prop_tester, G_TYPE_OBJECT);
169
prop_tester_init (PropTester* t)
172
; // neds unit test framework initialization: g_test_bug ("race initializing properties");
175
prop_tester_set_property (GObject *object,
181
prop_tester_class_init (PropTesterClass *c)
185
GObjectClass *gobject_class = G_OBJECT_CLASS (c);
187
gobject_class->set_property = prop_tester_set_property; /* silence GObject checks */
189
g_mutex_lock (sync_mutex);
190
g_cond_signal (sync_cond);
191
g_mutex_unlock (sync_mutex);
193
for (i = 0; i < 100; i++) /* wait a bit. */
196
call_counter_init (c);
197
param = g_param_spec_string ("name", "name_i18n",
198
"yet-more-wasteful-i18n",
200
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
201
G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB |
202
G_PARAM_STATIC_NICK);
203
g_object_class_install_property (gobject_class, PROP_NAME, param);
207
object_create (gpointer data)
209
GObject *obj = g_object_new (prop_tester_get_type(), "name", "fish", NULL);
210
g_object_unref (obj);
215
test_threaded_object_init (void)
218
g_mutex_lock (sync_mutex);
220
creator = g_thread_create (object_create, NULL, TRUE, NULL);
221
/* really provoke the race */
222
g_cond_wait (sync_cond, sync_mutex);
224
object_create (NULL);
225
g_mutex_unlock (sync_mutex);
227
g_thread_join (creator);
166
235
g_test_init (&argc, &argv, NULL);
238
sync_cond = g_cond_new();
239
sync_mutex = g_mutex_new();
169
241
g_test_add_func ("/GObject/threaded-class-init", test_threaded_class_init);
242
g_test_add_func ("/GObject/threaded-object-init", test_threaded_object_init);
171
244
return g_test_run();