map TRANSPORT_PRIORITY values directly. More...
#include <DirectPriorityMapper.h>
Public Member Functions | |
DirectPriorityMapper (Priority priority=0) | |
Construct with a priority value. | |
virtual | ~DirectPriorityMapper () |
virtual short | codepoint () const |
Access the mapped DiffServ codepoint value. | |
virtual short | thread_priority () const |
Access the mapped thread priority value. |
map TRANSPORT_PRIORITY values directly.
This implementation maps TRANSPORT_PRIORITY values directly to both DiffServ codepoint and thread priority values. The behavior is saturating - that is when the TRANSPORT_PRIORITY value is out of the target range, it is mapped to the nearest extremum.
DiffServ codepoint values are mapped within the closed interval [0,63], with the corresponding TRANSPORT_PRIORITY values mapped directly within this range.
Thread priorities are mapped to the system thread scheduler minimum value (obtained from the sched_get_priority_min(sched) system call, where available) up to the maximum value (obtained from the sched_get_priority_max(sched) system call, where available). The TRANSPORT_PRIORITY value of 0 is mapped to the minimum and a value of |max-min| is mapped to the maximum.
Definition at line 42 of file DirectPriorityMapper.h.
ACE_INLINE OpenDDS::DCPS::DirectPriorityMapper::DirectPriorityMapper | ( | Priority | priority = 0 |
) |
Construct with a priority value.
Definition at line 14 of file DirectPriorityMapper.inl.
00015 : PriorityMapper(priority) 00016 { 00017 }
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL OpenDDS::DCPS::DirectPriorityMapper::~DirectPriorityMapper | ( | ) | [virtual] |
Definition at line 22 of file DirectPriorityMapper.cpp.
short OpenDDS::DCPS::DirectPriorityMapper::codepoint | ( | ) | const [virtual] |
Access the mapped DiffServ codepoint value.
Implements OpenDDS::DCPS::PriorityMapper.
Definition at line 27 of file DirectPriorityMapper.cpp.
References ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, and OpenDDS::DCPS::PriorityMapper::priority().
Referenced by OpenDDS::DCPS::TcpConnection::active_establishment(), and OpenDDS::DCPS::UdpDataLink::open().
00028 { 00029 static const Priority dscp_min = 0; 00030 static const Priority dscp_max = 63; 00031 00032 // We know that the DiffServ codepoints range from a low number to a 00033 // high number, with the high number being a higher priority - which 00034 // is the ordering that the TRANSPORT_PRIORIY value has. 00035 short value = std::min(dscp_max, std::max(dscp_min, this->priority())); 00036 00037 if (OpenDDS::DCPS::DCPS_debug_level > 4) { 00038 ACE_DEBUG((LM_DEBUG, 00039 ACE_TEXT("(%P|%t) DirectPriorityMapper:codepoint() - ") 00040 ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ") 00041 ACE_TEXT("to codepoint %d.\n"), 00042 this->priority(), 00043 value)); 00044 } 00045 00046 return value; 00047 }
short OpenDDS::DCPS::DirectPriorityMapper::thread_priority | ( | ) | const [virtual] |
Access the mapped thread priority value.
Implements OpenDDS::DCPS::PriorityMapper.
Definition at line 50 of file DirectPriorityMapper.cpp.
References ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, OpenDDS::DCPS::PriorityMapper::priority(), and TheServiceParticipant.
Referenced by OpenDDS::DCPS::TransportSendStrategy::TransportSendStrategy().
00051 { 00052 static const int thread_min = TheServiceParticipant->priority_min(); 00053 static const int thread_max = TheServiceParticipant->priority_max(); 00054 static const int direction = (thread_max < thread_min)? -1: 1; 00055 static const int range = direction * (thread_max - thread_min); 00056 00057 short value = thread_min + direction * this->priority(); 00058 00059 if (this->priority() < 0) { 00060 value = thread_min; 00061 } 00062 00063 if (this->priority() > range) { 00064 value = thread_max; 00065 } 00066 00067 if (OpenDDS::DCPS::DCPS_debug_level > 4) { 00068 ACE_DEBUG((LM_DEBUG, 00069 ACE_TEXT("(%P|%t) DirectPriorityMapper:thread_priority() - ") 00070 ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ") 00071 ACE_TEXT("to thread priority %d.\n"), 00072 this->priority(), 00073 value)); 00074 } 00075 00076 return value; 00077 }