TAO_Continuous_Priority_Mapping Class Reference

Maps the first n CORBA priorities to the range of native priorities, where n is the number of native priorities. More...

#include <Continuous_Priority_Mapping.h>

Inheritance diagram for TAO_Continuous_Priority_Mapping:

Inheritance graph
[legend]
Collaboration diagram for TAO_Continuous_Priority_Mapping:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Continuous_Priority_Mapping (int policy=ACE_SCHED_OTHER)
 Constructor.
 ~TAO_Continuous_Priority_Mapping (void)
 Destructor.
CORBA::Boolean to_native (RTCORBA::Priority corba_priority, RTCORBA::NativePriority &native_priority)
 Convert CORBA priority to native priority.
CORBA::Boolean to_CORBA (RTCORBA::NativePriority native_priority, RTCORBA::Priority &corba_priority)
 Convert native priority to CORBA priority.

Private Attributes

int policy_
int min_
int max_

Detailed Description

Maps the first n CORBA priorities to the range of native priorities, where n is the number of native priorities.

The lowest native priority is mapped to CORBA priority 0, next higher native priority is mapped to CORBA priority 1, and so on. Since in all the operating systems where TAO is supported the native priority set contains less than 32767 priorities, part of the CORBA priority range is left unused. Consider NT as an example. NT native priorities -15 -2 -1 0 1 2 15 are mapped to CORBA priorities 0 1 2 3 4 5 6, respectively, and the rest of the CORBA priority range is not used.

This class was previously called Direct_Priority_Mapping.

Definition at line 50 of file Continuous_Priority_Mapping.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Continuous_Priority_Mapping::TAO_Continuous_Priority_Mapping ( int  policy = ACE_SCHED_OTHER  ) 

Constructor.

Definition at line 13 of file Continuous_Priority_Mapping.cpp.

00014   :  policy_ (policy)
00015    , min_ (ACE_Sched_Params::priority_min (this->policy_))
00016    , max_ (ACE_Sched_Params::priority_max (this->policy_))
00017 {
00018 }

TAO_Continuous_Priority_Mapping::~TAO_Continuous_Priority_Mapping ( void   ) 

Destructor.

Definition at line 20 of file Continuous_Priority_Mapping.cpp.

00021 {
00022 }


Member Function Documentation

CORBA::Boolean TAO_Continuous_Priority_Mapping::to_CORBA ( RTCORBA::NativePriority  native_priority,
RTCORBA::Priority &  corba_priority 
) [virtual]

Convert native priority to CORBA priority.

Implements TAO_Priority_Mapping.

Definition at line 80 of file Continuous_Priority_Mapping.cpp.

References min_, and ACE_Sched_Params::next_priority().

00082 {
00083 
00084 #if defined (ACE_WIN32)
00085 
00086   int current_native_priority = this->min_;
00087   for (corba_priority = 0; ; ++corba_priority)
00088     {
00089       if (current_native_priority == native_priority)
00090         return true;
00091 
00092       else if (current_native_priority == this->max_)
00093         return false;
00094 
00095       else
00096         current_native_priority =
00097           ACE_Sched_Params::next_priority (this->policy_,
00098                                            current_native_priority);
00099     }
00100 
00101 #else
00102 
00103   if (this->min_ < this->max_)
00104     {
00105       if (native_priority < this->min_
00106           || native_priority > this->max_)
00107         return false;
00108       corba_priority = native_priority - this->min_;
00109     }
00110   else if (this->min_ > this->max_)
00111     {
00112       if (native_priority > this->min_
00113           || native_priority < this->max_)
00114         return false;
00115       corba_priority = this->min_ - native_priority;
00116     }
00117   else if (this->min_ == this->max_)
00118     {
00119       if (native_priority != this->min_)
00120         return false;
00121       corba_priority = 0;
00122     }
00123 
00124   return true;
00125 
00126 #endif /* ACE_WIN32 */
00127 
00128 }

CORBA::Boolean TAO_Continuous_Priority_Mapping::to_native ( RTCORBA::Priority  corba_priority,
RTCORBA::NativePriority &  native_priority 
) [virtual]

Convert CORBA priority to native priority.

Implements TAO_Priority_Mapping.

Definition at line 25 of file Continuous_Priority_Mapping.cpp.

References min_, and ACE_Sched_Params::next_priority().

00027 {
00028   if (corba_priority < 0)
00029     return false;
00030 
00031 #if defined (ACE_WIN32)
00032 
00033   int current_native_priority = this->min_;
00034   int next_native_priority;
00035   for (int i = 1; i <= corba_priority; ++i)
00036     {
00037       next_native_priority =
00038         ACE_Sched_Params::next_priority (this->policy_,
00039                                          current_native_priority);
00040 
00041       if (next_native_priority == current_native_priority)
00042         return false;
00043 
00044       current_native_priority = next_native_priority;
00045     }
00046 
00047   native_priority = static_cast<RTCORBA::NativePriority> (current_native_priority);
00048   return true;
00049 
00050 #else
00051 
00052   if (this->min_ < this->max_)
00053     {
00054       native_priority = corba_priority + this->min_;
00055       if (native_priority > this->max_)
00056         return false;
00057     }
00058   else if (this->min_ > this->max_)
00059     {
00060       native_priority = this->min_ - corba_priority;
00061       if (native_priority < this->max_)
00062         return false;
00063     }
00064   else
00065     {
00066       // There is only one native priority.
00067       if (corba_priority != 0)
00068         return false;
00069 
00070       native_priority = this->min_;
00071     }
00072 
00073   return true;
00074 
00075 #endif /* ACE_WIN32 */
00076 
00077 }


Member Data Documentation

int TAO_Continuous_Priority_Mapping::max_ [private]

Definition at line 72 of file Continuous_Priority_Mapping.h.

int TAO_Continuous_Priority_Mapping::min_ [private]

Definition at line 71 of file Continuous_Priority_Mapping.h.

Referenced by to_CORBA(), and to_native().

int TAO_Continuous_Priority_Mapping::policy_ [private]

Definition at line 70 of file Continuous_Priority_Mapping.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:42:56 2010 for TAO_RTCORBA by  doxygen 1.4.7