3 #include "ace/Get_Opt.h"
6 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("k:n:i:"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
23 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
26 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
30 ACE_ERROR_RETURN ((LM_ERROR
,
39 // Indicates successful parsing of the command line
43 class Client
: public ACE_Task_Base
46 // Run the client thread
49 // Use the ACE_Task_Base class to run the client threads.
52 Client (int niterations
,
57 // The thread entry point.
61 // The number of iterations on each client thread.
64 // The IOR that we should use.
68 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
73 CORBA::ORB_init (argc
, argv
);
75 if (parse_args (argc
, argv
) != 0)
78 CORBA::Object_var object
=
79 orb
->string_to_object (ior
);
81 Simple_Server_var server
=
82 Simple_Server::_narrow (object
.in ());
84 if (CORBA::is_nil (server
.in ()))
86 ACE_ERROR_RETURN ((LM_ERROR
,
87 "Object reference <%s> is nil.\n",
92 Client
client (niterations
, ior
);
93 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
,
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 "Cannot activate client threads\n"),
99 client
.thr_mgr ()->wait ();
101 ACE_DEBUG ((LM_DEBUG
, "threads finished\n"));
105 catch (const CORBA::Exception
& ex
)
107 ex
._tao_print_exception ("Exception caught:");
114 // ****************************************************************
116 Client::Client (int niterations
,
118 : niterations_ (niterations
),
128 for (int i
= 0; i
< this->niterations_
; ++i
)
130 // If we are using a global ORB this is a nop, otherwise it
131 // initializes the ORB resources for this thread.
133 CORBA::String_var argv0
= CORBA::string_dup ("dummy_argv");
134 char* argv
[1] = { argv0
.inout () };
136 CORBA::ORB_init (argc
, argv
);
138 CORBA::Object_var object
=
139 orb
->string_to_object (this->ior_
);
141 Simple_Server_var server
=
142 Simple_Server::_narrow (object
.in ());
144 if (CORBA::is_nil (server
.in ()))
146 ACE_ERROR_RETURN ((LM_ERROR
,
147 "(%P|%t) Object reference <%s> is nil\n",
152 server
->test_method ();
153 if (TAO_debug_level
> 0 && i
% 100 == 0)
154 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n", i
));
157 catch (const CORBA::Exception
& ex
)
159 ex
._tao_print_exception ("MT_Client: exception raised");