3 #include "Client_Task.h"
4 #include "ace/Get_Opt.h"
5 #include "tao/AnyTypeCode/Any.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("n:k:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
25 nthreads
= ACE_OS::atoi(get_opts
.opt_arg());
30 ACE_ERROR_RETURN ((LM_ERROR
,
37 // Indicates successful parsing of the command line
42 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
49 CORBA::ORB_init (argc
, argv
);
51 if (parse_args (argc
, argv
) != 0)
54 CORBA::Object_var tmp
=
55 orb
->string_to_object(ior
);
57 Test::Hello_var hello
=
58 Test::Hello::_narrow(tmp
.in ());
60 if (CORBA::is_nil (hello
.in ()))
62 ACE_ERROR_RETURN ((LM_DEBUG
,
63 "Nil Test::Hello reference <%s>\n",
68 CORBA::Object_var poa_object
=
69 orb
->resolve_initial_references("RootPOA");
71 PortableServer::POA_var root_poa
=
72 PortableServer::POA::_narrow (poa_object
.in ());
74 PortableServer::POAManager_var poa_manager
=
75 root_poa
->the_POAManager ();
77 poa_manager
->activate ();
80 // Let the client perform the test in a separate thread
83 Client_Task
client (hello
.in (),
85 ACE_Thread_Manager::instance ());
87 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
, nthreads
) != 0)
89 ACE_ERROR_RETURN ((LM_ERROR
,
90 "ERROR - Cannot activate client threads\n"),
95 ACE_Time_Value thread_deadline
= ACE_OS::gettimeofday();
96 thread_deadline
+= 30;
98 if(client
.thr_mgr ()->wait (&thread_deadline
) == -1)
101 "ERROR - Timeout waiting for client threads\n"));
106 root_poa
->destroy (true, // ethernalize objects
107 false); // wait for completion
111 catch (const CORBA::Exception
& ex
)
113 ex
._tao_print_exception ("Exception caught:");