#include <DirectPriorityMapper.h>
Inheritance diagram for OpenDDS::DCPS::DirectPriorityMapper:
Public Member Functions | |
DirectPriorityMapper (Priority priority=0) | |
Construct with a priority value. | |
virtual | ~DirectPriorityMapper () |
Virtual destructor. | |
virtual short | codepoint () const |
Access the mapped DiffServ codepoint value. | |
virtual short | thread_priority () const |
Access the mapped thread priority value. |
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 40 of file DirectPriorityMapper.h.
ACE_INLINE OpenDDS::DCPS::DirectPriorityMapper::DirectPriorityMapper | ( | Priority | priority = 0 |
) |
Construct with a priority value.
Definition at line 12 of file DirectPriorityMapper.inl.
00013 : PriorityMapper(priority) 00014 { 00015 }
OpenDDS::DCPS::DirectPriorityMapper::~DirectPriorityMapper | ( | ) | [virtual] |
short OpenDDS::DCPS::DirectPriorityMapper::codepoint | ( | ) | const [virtual] |
Access the mapped DiffServ codepoint value.
Implements OpenDDS::DCPS::PriorityMapper.
Definition at line 25 of file DirectPriorityMapper.cpp.
References OpenDDS::DCPS::DCPS_debug_level.
Referenced by OpenDDS::DCPS::TcpConnection::active_establishment().
00026 { 00027 static const Priority dscp_min = 0; 00028 static const Priority dscp_max = 63; 00029 00030 // We know that the DiffServ codepoints range from a low number to a 00031 // high number, with the high number being a higher priority - which 00032 // is the ordering that the TRANSPORT_PRIORIY value has. 00033 short value = std::min(dscp_max, std::max(dscp_min, this->priority())); 00034 00035 if (OpenDDS::DCPS::DCPS_debug_level > 4) { 00036 ACE_DEBUG((LM_DEBUG, 00037 ACE_TEXT("(%P|%t) DirectPriorityMapper:codepoint() - ") 00038 ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ") 00039 ACE_TEXT("to codepoint %d.\n"), 00040 this->priority(), 00041 value)); 00042 } 00043 00044 return value; 00045 }
short OpenDDS::DCPS::DirectPriorityMapper::thread_priority | ( | ) | const [virtual] |
Access the mapped thread priority value.
Implements OpenDDS::DCPS::PriorityMapper.
Definition at line 48 of file DirectPriorityMapper.cpp.
References OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::PriorityMapper::priority(), and TheServiceParticipant.
Referenced by OpenDDS::DCPS::TransportSendStrategy::TransportSendStrategy().
00049 { 00050 static const int thread_min = TheServiceParticipant->priority_min(); 00051 static const int thread_max = TheServiceParticipant->priority_max(); 00052 static const int direction = (thread_max < thread_min)? -1: 1; 00053 static const int range = direction * (thread_max - thread_min); 00054 00055 short value = thread_min + direction * this->priority(); 00056 00057 if (this->priority() < 0) { 00058 value = thread_min; 00059 } 00060 00061 if (this->priority() > range) { 00062 value = thread_max; 00063 } 00064 00065 if (OpenDDS::DCPS::DCPS_debug_level > 4) { 00066 ACE_DEBUG((LM_DEBUG, 00067 ACE_TEXT("(%P|%t) DirectPriorityMapper:thread_priority() - ") 00068 ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ") 00069 ACE_TEXT("to thread priority %d.\n"), 00070 this->priority(), 00071 value)); 00072 } 00073 00074 return value; 00075 }