1 #include "Kokyu_dsrt.h"
3 #include "ace/Dynamic_Service.h"
4 #include "DSRT_Direct_Dispatcher_Impl_T.h"
5 #include "DSRT_CV_Dispatcher_Impl_T.h"
7 #if ! defined (__ACE_INLINE__)
8 #include "Kokyu_dsrt.inl"
9 #endif /* __ACE_INLINE__ */
13 template <class DSRT_Scheduler_Traits
>
15 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::implementation (DSRT_Dispatcher_Impl
<DSRT_Scheduler_Traits
>* impl
)
17 std::unique_ptr
<DSRT_Dispatcher_Impl
<DSRT_Scheduler_Traits
> > tmp_impl (impl
);
18 dispatcher_impl_
= std::move(tmp_impl
);
21 template <class DSRT_Scheduler_Traits
>
23 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::schedule (Guid_t guid
, const DSRT_QoSDescriptor
& qos
)
25 return dispatcher_impl_
->schedule (guid
, qos
);
28 template <class DSRT_Scheduler_Traits
>
30 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::update_schedule (Guid_t guid
, const DSRT_QoSDescriptor
& qos
)
32 return dispatcher_impl_
->update_schedule (guid
, qos
);
35 template <class DSRT_Scheduler_Traits
>
37 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::update_schedule (Guid_t guid
, Kokyu::Block_Flag_t flag
)
39 return dispatcher_impl_
->update_schedule (guid
, flag
);
42 template <class DSRT_Scheduler_Traits
>
44 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::cancel_schedule (Guid_t guid
)
46 return dispatcher_impl_
->cancel_schedule (guid
);
49 template <class DSRT_Scheduler_Traits
>
50 int DSRT_Dispatcher
<DSRT_Scheduler_Traits
>::shutdown ()
52 return dispatcher_impl_
->shutdown ();
55 template <class DSRT_Scheduler_Traits
>
56 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>*
57 DSRT_Dispatcher_Factory
<DSRT_Scheduler_Traits
>::
58 create_DSRT_dispatcher (const DSRT_ConfigInfo
& config_info
)
60 ACE_UNUSED_ARG ((config_info
));
62 DSRT_Dispatcher_Impl
<DSRT_Scheduler_Traits
>* tmp
;
63 DSRT_Dispatcher
<DSRT_Scheduler_Traits
>* disp
;
65 switch (config_info
.impl_type_
)
69 DSRT_Direct_Dispatcher_Impl
<DSRT_Scheduler_Traits
> (
70 config_info
.sched_policy_
,
71 config_info
.sched_scope_
),
78 DSRT_CV_Dispatcher_Impl
<DSRT_Scheduler_Traits
>(
79 config_info
.sched_policy_
,
80 config_info
.sched_scope_
),
85 ACE_ASSERT (tmp
!= 0);
86 ACE_NEW_RETURN (disp
, DSRT_Dispatcher
<DSRT_Scheduler_Traits
>, 0);
87 disp
->implementation (tmp
);
88 tmp
->init (config_info
);
92 template <class QoSDescriptor_t
>
93 int MUF_Comparator
<QoSDescriptor_t
>::
94 operator ()(const QoSDescriptor_t
& qos1
,
95 const QoSDescriptor_t
& qos2
)
97 if (qos1
.criticality_
> qos2
.criticality_
)
101 else if (qos2
.criticality_
> qos1
.criticality_
)
106 typename
QoSDescriptor_t::Now now_functor
;
107 Time_t now
= now_functor ();
109 Time_t exec_time1
= qos1
.exec_time_
;
110 Time_t deadline1
= qos1
.deadline_
;
111 Time_t laxity1
= deadline1
- now
- exec_time1
;
112 Time_t exec_time2
= qos2
.exec_time_
;
113 Time_t deadline2
= qos2
.deadline_
;
114 Time_t laxity2
= deadline2
- now
- exec_time2
;
116 if (laxity1
< laxity2
)
120 else if (laxity1
== laxity2
)
130 template <class QoSDescriptor
>
131 int MIF_Comparator
<QoSDescriptor
>::
132 operator ()(const QoSDescriptor
& qos1
,
133 const QoSDescriptor
& qos2
)
135 #ifdef KOKYU_DSRT_LOGGING
136 ACE_DEBUG ((LM_DEBUG
,
137 "(%t|%T):qos1.importance = %d, qos2.importance = %d\n",
138 qos1
.importance_
, qos2
.importance_
));
141 if (qos1
.importance_
> qos2
.importance_
)
145 else if (qos1
.importance_
== qos2
.importance_
)
155 template <class QoSDescriptor
>
156 int Fixed_Priority_Comparator
<QoSDescriptor
>::
157 operator ()(const QoSDescriptor
& qos1
,
158 const QoSDescriptor
& qos2
)
160 if (qos1
.priority_
> qos2
.priority_
)
164 else if (qos1
.priority_
== qos2
.priority_
)