1 #include "tao/RTCORBA/Continuous_Priority_Mapping.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "ace/Sched_Params.h"
7 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
9 TAO_Continuous_Priority_Mapping::TAO_Continuous_Priority_Mapping (int policy
)
11 , min_ (ACE_Sched_Params::priority_min (this->policy_
))
12 , max_ (ACE_Sched_Params::priority_max (this->policy_
))
16 TAO_Continuous_Priority_Mapping::~TAO_Continuous_Priority_Mapping ()
21 TAO_Continuous_Priority_Mapping::to_native (RTCORBA::Priority corba_priority
,
22 RTCORBA::NativePriority
&native_priority
)
24 if (corba_priority
< 0)
27 #if defined (ACE_WIN32)
29 int current_native_priority
= this->min_
;
30 int next_native_priority
;
31 for (int i
= 1; i
<= corba_priority
; ++i
)
33 next_native_priority
=
34 ACE_Sched_Params::next_priority (this->policy_
,
35 current_native_priority
);
37 if (next_native_priority
== current_native_priority
)
40 current_native_priority
= next_native_priority
;
43 native_priority
= static_cast<RTCORBA::NativePriority
> (current_native_priority
);
49 if (this->min_
< this->max_
)
51 native
= corba_priority
+ this->min_
;
52 if (native
> this->max_
)
55 else if (this->min_
> this->max_
)
57 native
= this->min_
- corba_priority
;
58 if (native
< this->max_
)
63 // There is only one native priority.
64 if (corba_priority
!= 0)
70 native_priority
= native
;
74 #endif /* ACE_WIN32 */
79 TAO_Continuous_Priority_Mapping::to_CORBA (RTCORBA::NativePriority native_priority
,
80 RTCORBA::Priority
&corba_priority
)
82 #if defined (ACE_WIN32)
84 int current_native_priority
= this->min_
;
85 for (corba_priority
= 0; ; ++corba_priority
)
87 if (current_native_priority
== native_priority
)
90 else if (current_native_priority
== this->max_
)
94 current_native_priority
=
95 ACE_Sched_Params::next_priority (this->policy_
,
96 current_native_priority
);
101 if (this->min_
< this->max_
)
103 if (native_priority
< this->min_
104 || native_priority
> this->max_
)
106 corba_priority
= native_priority
- this->min_
;
108 else if (this->min_
> this->max_
)
110 if (native_priority
> this->min_
111 || native_priority
< this->max_
)
113 corba_priority
= this->min_
- native_priority
;
115 else if (this->min_
== this->max_
)
117 if (native_priority
!= this->min_
)
124 #endif /* ACE_WIN32 */
128 TAO_END_VERSIONED_NAMESPACE_DECL
130 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */