2 #include "ace/Get_Opt.h"
4 #include "ace/Sched_Params.h"
5 #include "ace/OS_NS_errno.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://progress.ior");
9 int interval
= 0; // microseconds
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:t:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
25 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
29 interval
= ACE_OS::atoi (get_opts
.opt_arg ());
34 ACE_ERROR_RETURN ((LM_ERROR
,
43 // Indicates successful parsing of the command line
50 * Use the ACE_Task_Base class to run server threads
52 class Worker
: public ACE_Task_Base
56 Worker (CORBA::ORB_ptr orb
);
58 /// The thread entry point.
67 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
70 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
71 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
73 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
76 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
79 // Enable FIFO scheduling
80 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
82 ACE_SCOPE_PROCESS
)) != 0)
84 if (ACE_OS::last_error () == EPERM
)
87 "server (%P|%t): user is not superuser, "
88 "test runs in time-shared class\n"));
92 "server (%P|%t): sched_params failed\n"));
98 CORBA::ORB_init (argc
, argv
);
100 CORBA::Object_var poa_object
=
101 orb
->resolve_initial_references("RootPOA");
103 if (CORBA::is_nil (poa_object
.in ()))
104 ACE_ERROR_RETURN ((LM_ERROR
,
105 " (%P|%t) Unable to initialize the POA.\n"),
108 PortableServer::POA_var root_poa
=
109 PortableServer::POA::_narrow (poa_object
.in ());
111 PortableServer::POAManager_var poa_manager
=
112 root_poa
->the_POAManager ();
114 poa_manager
->activate ();
116 if (parse_args (argc
, argv
) != 0)
119 CORBA::Object_var progress_object
=
120 orb
->string_to_object (ior
);
122 Progress_var progress
=
123 Progress::_narrow (progress_object
.in ());
125 ACE_Time_Value
delay (0, interval
);
128 peer
.init (orb
.in (),
132 Worker
worker (orb
.in ());
133 if (worker
.activate (THR_NEW_LWP
| THR_JOINABLE
,
135 ACE_ERROR_RETURN ((LM_ERROR
,
136 "Cannot activate client threads\n"),
139 worker
.thr_mgr ()->wait ();
141 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
143 catch (const CORBA::Exception
& ex
)
145 ex
._tao_print_exception ("Caught exception:");
152 // ****************************************************************
154 Worker::Worker (CORBA::ORB_ptr orb
)
155 : orb_ (CORBA::ORB::_duplicate (orb
))
162 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) starting event loop\n"));