1 #include "ace/Get_Opt.h"
3 #include "tao/RTCORBA/RTCORBA.h"
4 #include "tao/ORB_Core.h"
6 #include "ace/OS_NS_unistd.h"
7 #include "../check_supported_priorities.cpp"
9 const ACE_TCHAR
*ior
= ACE_TEXT("file://ior_1");
11 int shutdown_server
= 0;
12 bool decreased
= false;
15 parse_args (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:i:"));
20 while ((c
= get_opts ()) != -1)
28 ior
= get_opts
.opt_arg ();
32 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
37 ACE_ERROR_RETURN ((LM_ERROR
,
41 "-x [shutdown server] "
47 // Indicates successful parsing of the command line
51 class Task
: public ACE_Task_Base
54 Task (ACE_Thread_Manager
&thread_manager
,
62 Task::Task (ACE_Thread_Manager
&thread_manager
,
64 : ACE_Task_Base (&thread_manager
),
65 orb_ (CORBA::ORB::_duplicate (orb
))
74 CORBA::Object_var object
=
75 this->orb_
->string_to_object (ior
);
78 test::_narrow (object
.in ());
84 this->orb_
->resolve_initial_references ("RTCurrent");
86 RTCORBA::Current_var current
=
87 RTCORBA::Current::_narrow (object
.in ());
89 // We need to set the client thread CORBA priority
90 current
->the_priority (get_implicit_thread_CORBA_priority (this->orb_
.in ()));
94 for (int i
= 0; i
!= iterations
; ++i
)
102 // Each 2 iterations sleep 5 seconds
107 // Assert disappears on with optimizations on.
112 // Number of threads increased, so store this.
113 ACE_DEBUG ((LM_DEBUG
, "Thread count increased to %d\n", mtc
));
118 // Number of threads decreased!
119 ACE_DEBUG ((LM_DEBUG
, "Thread count decreased to %d\n", mtc
));
133 ACE_ASSERT (re
== 0);
134 // Assert disappears on with optimizations on.
139 ACE_ERROR ((LM_ERROR
, "Dynamic thread count should be 0, not %d\n", end
));
142 catch (const CORBA::Exception
& ex
)
144 ex
._tao_print_exception ("Exception caught:");
152 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
157 CORBA::ORB_init (argc
, argv
);
160 parse_args (argc
, argv
);
166 CORBA::Object_var object
=
167 orb
->string_to_object (ior
);
170 test::_narrow (object
.in ());
176 // Thread Manager for managing task.
177 ACE_Thread_Manager thread_manager
;
180 Task
task (thread_manager
,
183 // Task activation flags.
187 orb
->orb_core ()->orb_params ()->thread_creation_flags ();
191 task
.activate (flags
);
196 ACE_ERROR_RETURN ((LM_ERROR
,
197 "Cannot create thread with scheduling policy %s\n"
198 "because the user does not have the appropriate privileges, terminating program....\n"
199 "Check svc.conf options and/or run as root\n",
200 sched_policy_name (orb
->orb_core ()->orb_params ()->ace_sched_policy ())),
208 // Wait for task to exit.
210 thread_manager
.wait ();
211 ACE_ASSERT (result
!= -1);
213 if (decreased
== false)
215 ACE_ERROR_RETURN ((LM_ERROR
, "ERROR: Number of threads didn't decrease\n"), -1);
219 catch (const CORBA::Exception
& ex
)
221 ex
._tao_print_exception ("Exception caught");