blob: 7c899357a9b28b9a1d80ff490893f8cdf07733aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// $Id$
#include "tao/orbconf.h"
#if defined (TAO_HAS_RT_CORBA)
#include "tao/Direct_Priority_Mapping.h"
#include "tao/debug.h"
#include "ace/Sched_Params.h"
#if !defined (__ACE_INLINE__)
# include "tao/Direct_Priority_Mapping.i"
#endif /* ! __ACE_INLINE__ */
ACE_RCSID(tao, Direct_Priority_Mapping, "$Id$")
TAO_Direct_Priority_Mapping::TAO_Direct_Priority_Mapping (int policy)
: policy_ (policy)
{
this->min_ = ACE_Sched_Params::priority_min (this->policy_);
this->max_ = ACE_Sched_Params::priority_max (this->policy_);
}
TAO_Direct_Priority_Mapping::~TAO_Direct_Priority_Mapping (void)
{
}
CORBA::Boolean
TAO_Direct_Priority_Mapping::to_native (RTCORBA::Priority corba_priority,
RTCORBA::NativePriority &native_priority)
{
if (corba_priority < 0)
return 0;
if (this->min_ < this->max_)
{
native_priority = corba_priority + this->min_;
if (native_priority > this->max_)
return 0;
}
else if (this->min_ > this->max_)
{
native_priority = this->min_ - corba_priority;
if (native_priority < this->max_)
return 0;
}
else
{
// There is only one native priority.
if (corba_priority != 0)
return 0;
native_priority = this->min_;
}
return 1;
}
CORBA::Boolean
TAO_Direct_Priority_Mapping::to_CORBA (RTCORBA::NativePriority native_priority,
RTCORBA::Priority &corba_priority)
{
if (this->min_ < this->max_)
{
if (native_priority < this->min_
|| native_priority > this->max_)
return 0;
corba_priority = native_priority - this->min_;
}
else if (this->min_ > this->max_)
{
if (native_priority > this->min_
|| native_priority < this->max_)
return 0;
corba_priority = this->min_ - native_priority;
}
else if (this->min_ == this->max_)
{
if (native_priority != this->min_)
return 0;
corba_priority = 0;
}
return 1;
}
#endif /* TAO_HAS_RT_CORBA */
|