1 #include "../Scheduler.h"
2 #include "tao/RTScheduling/RTScheduler_Manager.h"
4 #include "Thread_Action.h"
5 #include "ace/Thread_Manager.h"
6 #include "ace/SString.h"
9 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
12 RTScheduling::Current_var current
;
14 const char * name
= 0;
15 CORBA::Policy_ptr sched_param
= 0;
16 CORBA::Policy_ptr implicit_sched_param
= 0;
18 Test_Thread_Action thread_action
;
22 orb
= CORBA::ORB_init (argc
,
25 CORBA::Object_var manager_obj
= orb
->resolve_initial_references ("RTSchedulerManager");
27 TAO_RTScheduler_Manager_var manager
= TAO_RTScheduler_Manager::_narrow (manager_obj
.in ());
29 TAO_Scheduler
* scheduler
;
30 ACE_NEW_RETURN (scheduler
,
31 TAO_Scheduler (orb
.in ()),
33 RTScheduling::Scheduler_var safe_scheduler
= scheduler
;
35 manager
->rtscheduler (scheduler
);
37 CORBA::Object_var current_obj
= orb
->resolve_initial_references ("RTScheduler_Current");
39 current
= RTScheduling::Current::_narrow (current_obj
.in ());
44 "Invoking DT spawn without calling begin_scheduling_segment...\n"));
46 ACE_CString
data ("Harry Potter");
47 RTScheduling::DistributableThread_var dt
=
48 current
->spawn (&thread_action
,
49 const_cast<char *> (data
.c_str ()),
56 catch (const CORBA::BAD_INV_ORDER
& )
59 "Spawn should be in the context of a Scheduling Segment - Expected Exception\n"));
61 catch (const CORBA::Exception
& ex
)
63 ex
._tao_print_exception ("\n");
67 "Start - Scheduling Segment...\n"));
69 current
->begin_scheduling_segment ("Potter",
71 implicit_sched_param
);
74 RTScheduling::Current::IdType_var id
= current
->id ();
75 ACE_OS::memcpy (&count
,
80 "The Current DT Guid is %d\n",
83 //Initialize data to be passed to the Thread_Action::do method
85 spawn_data
.data
= "Harry Potter";
86 spawn_data
.current
= RTScheduling::Current::_duplicate (current
.in ());
89 "Spawning a new DT...\n"));
90 RTScheduling::DistributableThread_var dt
=
91 current
->spawn (&thread_action
,
99 current
->end_scheduling_segment (name
);
100 ACE_DEBUG ((LM_DEBUG
,
101 "End - Scheduling Segment %d\n",
104 ACE_Thread_Manager::instance ()->wait ();
108 catch (const CORBA::Exception
& ex
)
110 ex
._tao_print_exception ("Caught Exception\n");