2 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:i:"));
16 while ((c
= get_opts ()) != -1)
24 ior
= get_opts
.opt_arg ();
28 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
33 ACE_ERROR_RETURN ((LM_ERROR
,
41 // Indicates successful parsing of the command line
45 class Worker
: public ACE_Task_Base
48 Worker (CORBA::ORB_ptr orb
);
51 virtual void run_test (void);
52 // The actual implementation of the test
54 // = The Task_Base methods
55 virtual int svc (void);
63 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
68 CORBA::ORB_init (argc
, argv
);
70 if (parse_args (argc
, argv
) != 0)
73 Worker
worker (orb
.in ());
75 if (worker
.activate (THR_NEW_LWP
| THR_JOINABLE
,
77 ACE_ERROR_RETURN ((LM_ERROR
,
78 "(%P|%t) Cannot activate worker threads\n"),
81 ACE_Time_Value
tv (5, 0);
85 // Now run a test in the main thread, just to confuse matters a
89 worker
.thr_mgr ()->wait ();
93 CORBA::Object_var object
=
94 orb
->string_to_object (ior
);
96 Simple_Server_var server
=
97 Simple_Server::_narrow (object
.in ());
104 catch (const CORBA::Exception
& ex
)
106 ex
._tao_print_exception ("Exception caught in main:");
113 // ****************************************************************
115 Worker::Worker (CORBA::ORB_ptr orb
)
116 : orb_ (CORBA::ORB::_duplicate (orb
))
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception ("Exception caught in thread (%t)\n");
136 Worker::run_test (void)
138 for (int j
= 0; j
!= niterations
; ++j
)
140 CORBA::Object_var object
=
141 this->orb_
->string_to_object (ior
);
143 CORBA::Boolean is_simple_server
=
144 object
->_is_a ("IDL:Simple_Server:1.0");
145 if (!is_simple_server
)
146 ACE_DEBUG ((LM_DEBUG
,
147 "(%P|%t) unexpected result from _is_a()\n"));
150 CORBA::Object_var object
=
151 this->orb_
->string_to_object (ior
);
153 Simple_Server_var server
=
154 Simple_Server::_narrow (object
.in ());
156 if (CORBA::is_nil (server
.in ()))
158 ACE_ERROR ((LM_ERROR
,
159 "Object reference <%s> is nil.\n",
164 for (int i
= 0; i
!= niterations
; ++i
)
167 server
->test_is_a ("IDL:Foo:1.0");
170 ACE_DEBUG ((LM_DEBUG
,
171 "(%P|%t) unexpected result = %d\n",