#include <Linear_Priority_Mapping.h>
Inheritance diagram for TAO_Linear_Priority_Mapping:
Public Member Functions | |
TAO_Linear_Priority_Mapping (long policy) | |
Default constructor. | |
virtual | ~TAO_Linear_Priority_Mapping (void) |
The destructor. | |
virtual CORBA::Boolean | to_native (RTCORBA::Priority corba_priority, RTCORBA::NativePriority &native_priority) |
virtual CORBA::Boolean | to_CORBA (RTCORBA::NativePriority native_priority, RTCORBA::Priority &corba_priority) |
Private Attributes | |
long | policy_ |
The scheduling policy. | |
int const | min_ |
int const | max_ |
This implementation uses linear mapping between the range of priorities for a given scheduling class (ACE_SCHED_OTHER, ACE_SCHED_FIFO, ACE_SCHED_RR) and the valid range of CORBA priorities (0...32767)
Definition at line 46 of file Linear_Priority_Mapping.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Linear_Priority_Mapping::TAO_Linear_Priority_Mapping | ( | long | policy | ) |
Default constructor.
Definition at line 19 of file Linear_Priority_Mapping.cpp.
00020 : policy_ (policy) 00021 , min_ (ACE_Sched_Params::priority_min (this->policy_)) 00022 , max_ (ACE_Sched_Params::priority_max (this->policy_)) 00023 { 00024 }
TAO_Linear_Priority_Mapping::~TAO_Linear_Priority_Mapping | ( | void | ) | [virtual] |
CORBA::Boolean TAO_Linear_Priority_Mapping::to_CORBA | ( | RTCORBA::NativePriority | native_priority, | |
RTCORBA::Priority & | corba_priority | |||
) | [virtual] |
Implements TAO_Priority_Mapping.
Definition at line 85 of file Linear_Priority_Mapping.cpp.
References ACE_DEBUG, LM_DEBUG, max_, min_, and ACE_Sched_Params::next_priority().
00087 { 00088 #if defined (ACE_WIN32) 00089 00090 // Iterate over native priorities in order to 1) make sure 00091 // <native_priority> argument contains a valid value, 2) count its 00092 // index among all valid native pr. values, 3) get the total number 00093 // of native priority values for the current platform. 00094 00095 int total; 00096 int native_priority_index = 0; 00097 int current_priority = this->min_; 00098 for (total = 1; ; ++total) 00099 { 00100 if (native_priority == current_priority) 00101 native_priority_index = total; 00102 00103 if (current_priority == this->max_) 00104 break; 00105 00106 current_priority = 00107 ACE_Sched_Params::next_priority (this->policy_, 00108 current_priority); 00109 } 00110 00111 if (native_priority_index == 0) 00112 return 0; 00113 00114 int delta = total - 1; 00115 if (delta != 0) 00116 { 00117 corba_priority = static_cast<RTCORBA::Priority> (RTCORBA::minPriority 00118 + ((RTCORBA::maxPriority - RTCORBA::minPriority) 00119 * (native_priority_index - 1) / delta)); 00120 } 00121 else 00122 { 00123 // There is only one native priority. 00124 corba_priority = RTCORBA::minPriority; 00125 } 00126 00127 return 1; 00128 00129 #else 00130 00131 if ((this->min_ < this->max_ 00132 && (native_priority < this->min_ 00133 || native_priority > this->max_)) 00134 || (this->min_ > this->max_ 00135 && (native_priority < this->max_ 00136 || native_priority > this->min_))) 00137 { 00138 ACE_DEBUG ((LM_DEBUG, 00139 "TAO (%P|%t) - Linear_Priority_Mapping::to_CORBA: " 00140 " priority %d out of range [%d,%d]\n", 00141 native_priority, this->min_, this->max_)); 00142 return 0; 00143 } 00144 00145 int delta = this->max_ - this->min_; 00146 if (delta != 0) 00147 { 00148 corba_priority = 00149 RTCORBA::minPriority 00150 + ((RTCORBA::maxPriority - RTCORBA::minPriority) 00151 * (native_priority - this->min_) / delta); 00152 } 00153 else 00154 { 00155 // There is only one native priority. 00156 if (native_priority != this->min_) 00157 return 0; 00158 corba_priority = RTCORBA::minPriority; 00159 } 00160 00161 return 1; 00162 00163 #endif /* ACE_WIN32 */ 00164 }
CORBA::Boolean TAO_Linear_Priority_Mapping::to_native | ( | RTCORBA::Priority | corba_priority, | |
RTCORBA::NativePriority & | native_priority | |||
) | [virtual] |
Implements TAO_Priority_Mapping.
Definition at line 31 of file Linear_Priority_Mapping.cpp.
References max_, min_, and ACE_Sched_Params::next_priority().
00034 { 00035 if (corba_priority < RTCORBA::minPriority 00036 // The line below will always be false unless the value of 00037 // RTCORBA::maxPriority, which is now assigned the value of 00038 // 32767, is changed in RTCORBA.pidl. 00039 // || corba_priority > RTCORBA::maxPriority 00040 ) 00041 { 00042 return 0; 00043 } 00044 00045 #if defined (ACE_WIN32) 00046 // Count up the number of distinct native priorities on current 00047 // platform. 00048 int n; 00049 int current_priority = this->min_; 00050 for (n = 1; current_priority != this->max_; ++n) 00051 { 00052 current_priority = 00053 ACE_Sched_Params::next_priority (this->policy_, 00054 current_priority); 00055 } 00056 int native_priority_index = 00057 1 00058 + ((n - 1) 00059 * corba_priority 00060 / (RTCORBA::maxPriority - RTCORBA::minPriority)); 00061 00062 // Now, find the value corresponding to this index. 00063 native_priority = static_cast<RTCORBA::NativePriority> (this->min_); 00064 for (int i = 2; i <= native_priority_index; ++i) 00065 { 00066 native_priority = static_cast<RTCORBA::NativePriority> 00067 (ACE_Sched_Params::next_priority (this->policy_, native_priority)); 00068 } 00069 return 1; 00070 00071 #else 00072 00073 native_priority = 00074 this->min_ 00075 + ((this->max_ - this->min_) 00076 * corba_priority 00077 / (RTCORBA::maxPriority - RTCORBA::minPriority)); 00078 00079 return 1; 00080 00081 #endif /* ACE_WIN32 */ 00082 }
int const TAO_Linear_Priority_Mapping::max_ [private] |
int const TAO_Linear_Priority_Mapping::min_ [private] |
long TAO_Linear_Priority_Mapping::policy_ [private] |