=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / examples / RTScheduling / MIF_Scheduler / MIF_DT_Creator.cpp
blob52754b1de2792a78a2ef6b83efef552167769771
1 #include "MIF_DT_Creator.h"
2 #include "test.h"
3 #include "MIF_Task.h"
5 MIF_DT_Creator::MIF_DT_Creator ()
7 DT_TEST::instance ()->dt_creator (this);
10 Thread_Task*
11 MIF_DT_Creator::create_thr_task (int importance,
12 time_t start_time,
13 int load,
14 int iter,
15 int dist,
16 char *job_name)
18 MIF_Task* task;
19 ACE_NEW_RETURN (task,
20 MIF_Task (importance,
21 start_time,
22 load,
23 iter,
24 dist,
25 job_name,
26 this),
27 0);
28 return task;
31 CORBA::Policy_ptr
32 MIF_DT_Creator::sched_param (int importance)
34 return DT_TEST::instance ()->scheduler ()->create_segment_scheduling_parameter (importance);
37 void
38 MIF_DT_Creator::yield (time_t suspend_time,
39 Thread_Task*)
41 try
43 CORBA::Object_var object =
44 this->orb_->resolve_initial_references ("RTScheduler_Current");
45 RTScheduling::Current_var current =
46 RTScheduling::Current::_narrow (object.in ());
48 ACE_Time_Value const sus_time_value (suspend_time);
49 ACE_Time_Value now (ACE_OS::gettimeofday ());
50 while (((now - *base_time_) < sus_time_value) || (suspend_time == 1))
52 ACE_OS::sleep (1);
53 CORBA::Policy_var sched_param;
54 sched_param = this->sched_param (100);
55 const char * name = 0;
56 current->update_scheduling_segment (name,
57 sched_param.in (),
58 sched_param.in ());
59 now = ACE_OS::gettimeofday ();
60 if (suspend_time == 1)
61 break;
64 catch (const CORBA::Exception& ex)
66 ex._tao_print_exception ("Caught exception:");
70 int
71 MIF_DT_Creator::total_load ()
73 return 1000;
76 void
77 MIF_DT_Creator::wait ()
79 while (active_dt_count_ > 0 || active_job_count_ > 0)
81 try
83 (void)this->orb_->work_pending ();
85 catch (const CORBA::BAD_INV_ORDER &)
87 // If there is BAD_INV_ORDER exception there is
88 // no point in running this loop any more.
89 break;
91 yield(1,0);
95 ACE_STATIC_SVC_DEFINE(MIF_DT_Creator,
96 ACE_TEXT ("MIF_DT_Creator"),
97 ACE_SVC_OBJ_T,
98 &ACE_SVC_NAME (MIF_DT_Creator),
99 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
102 ACE_FACTORY_DEFINE (ACE_Local_Service, MIF_DT_Creator)