1 #include "ace/Get_Opt.h"
4 #include "tao/ORB_Core.h"
5 #include "tao/RTCORBA/RTCORBA.h"
6 #include "../check_supported_priorities.cpp"
8 static const ACE_TCHAR
*ior
= 0;
9 static int iterations
= 5;
10 static int shutdown_server
= 0;
11 static RTCORBA::Priority default_thread_priority
;
14 parse_args (int argc
, ACE_TCHAR
**argv
)
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:i:x"));
19 while ((c
= get_opts ()) != -1)
23 ior
= get_opts
.opt_arg ();
27 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
36 ACE_ERROR_RETURN ((LM_ERROR
,
47 ACE_ERROR_RETURN ((LM_ERROR
,
48 "An IOR must be specified\n"),
54 class Task
: public ACE_Task_Base
57 Task (ACE_Thread_Manager
&thread_manager
,
65 Task::Task (ACE_Thread_Manager
&thread_manager
,
67 : ACE_Task_Base (&thread_manager
),
68 orb_ (CORBA::ORB::_duplicate (orb
))
77 CORBA::Object_var object
=
78 this->orb_
->resolve_initial_references ("RTCurrent");
80 RTCORBA::Current_var current
=
81 RTCORBA::Current::_narrow (object
.in ());
83 default_thread_priority
=
84 get_implicit_thread_CORBA_priority (this->orb_
.in ());
87 this->orb_
->string_to_object (ior
);
90 test::_narrow (object
.in ());
92 for (int i
= 0; i
< iterations
; i
++)
94 current
->the_priority (default_thread_priority
);
96 CORBA::Short priority
=
99 if (priority
!= TAO_INVALID_PRIORITY
)
101 current
->the_priority (priority
);
103 test
->prioritized_method ();
112 catch (const CORBA::Exception
& ex
)
114 ex
._tao_print_exception ("Unexpected exception!");
122 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
127 CORBA::ORB_init (argc
, argv
);
130 parse_args (argc
, argv
);
134 // Make sure we can support multiple priorities that are required
136 if (!check_supported_priorities (orb
.in ()))
139 // The following finds out the lowest priority for this
140 // scheduling policy. This will give us the biggest range on NT
141 // since the default priority is 0 where as the lowest priority
143 int minimum_priority
=
144 ACE_Sched_Params::priority_min (orb
->orb_core ()->orb_params ()->ace_sched_policy ());
146 // Thread Manager for managing task.
147 ACE_Thread_Manager thread_manager
;
150 Task
task (thread_manager
,
153 // Task activation flags.
157 orb
->orb_core ()->orb_params ()->thread_creation_flags ();
161 task
.activate (flags
,
168 ACE_ERROR_RETURN ((LM_ERROR
,
169 "Cannot create thread with scheduling policy %C\n"
170 "because the user does not have the appropriate privileges, terminating program....\n"
171 "Check svc.conf options and/or run as root\n",
172 sched_policy_name (orb
->orb_core ()->orb_params ()->ace_sched_policy ())),
180 // Wait for task to exit.
182 thread_manager
.wait ();
183 ACE_ASSERT (result
!= -1);
185 catch (const CORBA::Exception
& ex
)
187 ex
._tao_print_exception ("Unexpected exception!");