3 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
9 int server_shutdown
= 0;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:i:x"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
24 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
27 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
34 ACE_ERROR_RETURN ((LM_ERROR
,
43 // Indicates successful parsing of the command line
47 class Client
: public ACE_Task_Base
50 // Run the client thread
53 // Use the ACE_Task_Base class to run the client threads.
56 Client (Simple_Server_ptr server
, int niterations
);
59 /// The thread entry point.
63 Simple_Server_var server_
;
67 // The number of iterations on each client thread.
71 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
76 CORBA::ORB_init (argc
, argv
);
78 if (parse_args (argc
, argv
) != 0)
81 CORBA::Object_var object
=
82 orb
->string_to_object (ior
);
84 Simple_Server_var server
=
85 Simple_Server::_narrow (object
.in ());
87 if (CORBA::is_nil (server
.in ()))
89 ACE_ERROR_RETURN ((LM_ERROR
,
90 "Object reference <%s> is nil.\n",
100 Client
client (server
.in (), niterations
);
101 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
,
103 ACE_ERROR_RETURN ((LM_ERROR
,
104 "Cannot activate client threads\n"),
107 client
.thr_mgr ()->wait ();
109 ACE_DEBUG ((LM_DEBUG
, "threads finished\n"));
113 catch (const CORBA::Exception
& ex
)
115 ex
._tao_print_exception ("Caught exception:");
122 // ****************************************************************
124 Client::Client (Simple_Server_ptr server
,
126 : server_ (Simple_Server::_duplicate (server
)),
127 niterations_ (niterations
)
136 for (int i
= 0; i
< this->niterations_
; ++i
)
138 this->server_
->test_method ();
140 if (TAO_debug_level
> 0 && i
% 100 == 0)
141 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n",
145 catch (const CORBA::Exception
&)
147 ACE_DEBUG ((LM_DEBUG
,
148 "(%P|%t) Expected exceptions\n"));