10
#define PROP_IN_MAIN 1
11
#define PROP_NON_MAIN 2
13
static GThread *main_thread = NULL;
16
get_fn (BonoboPropertyBag *bag,
19
CORBA_Environment *ev,
22
fprintf (stderr, "Check property %d\n", arg_id);
23
if (arg_id == PROP_IN_MAIN)
24
g_assert (g_thread_self () == main_thread);
26
g_assert (g_thread_self () != main_thread);
27
BONOBO_ARG_SET_BOOLEAN (arg, TRUE);
33
Bonobo_PropertyBag pb;
37
test_prop (TestClosure *tc, CORBA_Environment *ev)
39
g_assert (bonobo_pbclient_get_boolean (tc->pb, tc->prop, ev) == tc->value);
40
g_assert (!BONOBO_EX (ev));
44
G_LOCK_DEFINE_STATIC (running_threads);
47
test_thread (gpointer data)
50
CORBA_Environment ev[1];
51
TestClosure *tc = data;
53
CORBA_exception_init (ev);
55
for (i = 0; i < NUM_GETS; i++)
58
G_LOCK (running_threads);
60
G_UNLOCK (running_threads);
62
CORBA_exception_free (ev);
68
wakeup_fn (gpointer data)
74
test_threads (TestClosure *tc)
78
GThread *threads [NUM_THREADS];
80
running_threads = NUM_THREADS;
82
for (i = 0; i < NUM_THREADS; i++)
83
threads [i] = g_thread_create (test_thread, tc, TRUE, NULL);
85
wakeup = g_timeout_add (100, wakeup_fn, NULL);
88
G_LOCK (running_threads);
89
if (running_threads == 0) {
90
G_UNLOCK (running_threads);
93
G_UNLOCK (running_threads);
94
g_main_context_iteration (NULL, TRUE);
97
g_source_remove (wakeup);
99
for (i = 0; i < NUM_THREADS; i++) {
100
if (!(g_thread_join (threads [i]) == tc))
101
g_error ("Wierd thread join problem '%d'", i);
106
main (int argc, char *argv [])
108
CORBA_Environment ev[1];
109
BonoboPropertyBag *pb;
110
PortableServer_POA poa;
115
CORBA_exception_init (ev);
117
if (bonobo_init (&argc, argv) == FALSE)
118
g_error ("Can not bonobo_init");
121
main_thread = g_thread_self ();
124
poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST);
125
pb = g_object_new (BONOBO_TYPE_PROPERTY_BAG,
127
bonobo_property_bag_construct
128
(pb, g_cclosure_new (G_CALLBACK (get_fn), NULL, NULL), NULL,
129
bonobo_event_source_new ());
130
bonobo_property_bag_add (pb, "non_main", PROP_NON_MAIN, TC_CORBA_boolean,
131
NULL, "non_main", BONOBO_PROPERTY_READABLE);
132
tc.prop = "non_main";
134
tc.pb = BONOBO_OBJREF (pb);
137
bonobo_object_unref (pb);
141
pb = bonobo_property_bag_new (get_fn, NULL, NULL);
142
bonobo_property_bag_add (pb, "in_main", PROP_IN_MAIN, TC_CORBA_boolean,
143
NULL, "in_main", BONOBO_PROPERTY_READABLE);
147
tc.pb = BONOBO_OBJREF (pb);
152
bonobo_object_unref (pb);
155
CORBA_exception_free (ev);
157
return bonobo_debug_shutdown ();