Public Member Functions | Private Attributes

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_Continuous_Priority_Mapping::TAO_Continuous_Priority_Mapping ( int  policy = ACE_SCHED_OTHER  ) 

Constructor.

Definition at line 13 of file Continuous_Priority_Mapping.cpp.

TAO_Continuous_Priority_Mapping::~TAO_Continuous_Priority_Mapping ( void   ) 

Destructor.

Definition at line 20 of file Continuous_Priority_Mapping.cpp.

{
}


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 83 of file Continuous_Priority_Mapping.cpp.

{

#if defined (ACE_WIN32)

  int current_native_priority = this->min_;
  for (corba_priority = 0; ; ++corba_priority)
    {
      if (current_native_priority == native_priority)
        return true;

      else if (current_native_priority == this->max_)
        return false;

      else
        current_native_priority =
          ACE_Sched_Params::next_priority (this->policy_,
                                           current_native_priority);
    }

#else

  if (this->min_ < this->max_)
    {
      if (native_priority < this->min_
          || native_priority > this->max_)
        return false;
      corba_priority = native_priority - this->min_;
    }
  else if (this->min_ > this->max_)
    {
      if (native_priority > this->min_
          || native_priority < this->max_)
        return false;
      corba_priority = this->min_ - native_priority;
    }
  else if (this->min_ == this->max_)
    {
      if (native_priority != this->min_)
        return false;
      corba_priority = 0;
    }

  return true;

#endif /* ACE_WIN32 */

}

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.

{
  if (corba_priority < 0)
    return false;

#if defined (ACE_WIN32)

  int current_native_priority = this->min_;
  int next_native_priority;
  for (int i = 1; i <= corba_priority; ++i)
    {
      next_native_priority =
        ACE_Sched_Params::next_priority (this->policy_,
                                         current_native_priority);

      if (next_native_priority == current_native_priority)
        return false;

      current_native_priority = next_native_priority;
    }

  native_priority = static_cast<RTCORBA::NativePriority> (current_native_priority);
  return true;

#else
  int native;

  if (this->min_ < this->max_)
    {
      native = corba_priority + this->min_;
      if (native > this->max_)
        return false;
    }
  else if (this->min_ > this->max_)
    {
      native = this->min_ - corba_priority;
      if (native < this->max_)
        return false;
    }
  else
    {
      // There is only one native priority.
      if (corba_priority != 0)
        return false;

      native = this->min_;
    }

  native_priority = native;

  return true;

#endif /* ACE_WIN32 */

}


Member Data Documentation

Definition at line 72 of file Continuous_Priority_Mapping.h.

Definition at line 71 of file Continuous_Priority_Mapping.h.

Definition at line 70 of file Continuous_Priority_Mapping.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines