OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | List of all members
OpenDDS::DCPS::DirectPriorityMapper Class Reference

map TRANSPORT_PRIORITY values directly. More...

#include <DirectPriorityMapper.h>

Inheritance diagram for OpenDDS::DCPS::DirectPriorityMapper:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::DirectPriorityMapper:
Collaboration graph
[legend]

Public Member Functions

 DirectPriorityMapper (Priority priority=0)
 Construct with a priority value. More...
 
virtual ~DirectPriorityMapper ()
 
virtual short codepoint () const
 Access the mapped DiffServ codepoint value. More...
 
virtual short thread_priority () const
 Access the mapped thread priority value. More...
 
- Public Member Functions inherited from OpenDDS::DCPS::PriorityMapper
 PriorityMapper (Priority priority=0)
 Construct with a priority value. More...
 
virtual ~PriorityMapper ()
 
Prioritypriority ()
 Accessors for the TRANSPORT_PRIORITY value. More...
 
Priority priority () const
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DirectPriorityMapper()

ACE_INLINE OpenDDS::DCPS::DirectPriorityMapper::DirectPriorityMapper ( Priority  priority = 0)

Construct with a priority value.

Definition at line 14 of file DirectPriorityMapper.inl.

References OPENDDS_END_VERSIONED_NAMESPACE_DECL.

16 {
17 }
PriorityMapper(Priority priority=0)
Construct with a priority value.
Priority & priority()
Accessors for the TRANSPORT_PRIORITY value.

◆ ~DirectPriorityMapper()

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL OpenDDS::DCPS::DirectPriorityMapper::~DirectPriorityMapper ( )
virtual

Definition at line 22 of file DirectPriorityMapper.cpp.

23 {
24 }

Member Function Documentation

◆ codepoint()

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_DEBUG, ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, OpenDDS::DCPS::PriorityMapper::priority(), and value.

Referenced by OpenDDS::DCPS::TcpConnection::on_active_connection_established(), and OpenDDS::DCPS::UdpDataLink::open().

28 {
29  static const Priority dscp_min = 0;
30  static const Priority dscp_max = 63;
31 
32  // We know that the DiffServ codepoints range from a low number to a
33  // high number, with the high number being a higher priority - which
34  // is the ordering that the TRANSPORT_PRIORIY value has.
35  short value = std::min(dscp_max, std::max(dscp_min, this->priority()));
36 
38  ACE_DEBUG((LM_DEBUG,
39  ACE_TEXT("(%P|%t) DirectPriorityMapper:codepoint() - ")
40  ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ")
41  ACE_TEXT("to codepoint %d.\n"),
42  this->priority(),
43  value));
44  }
45 
46  return value;
47 }
#define ACE_DEBUG(X)
const LogLevel::Value value
Definition: debug.cpp:61
Priority & priority()
Accessors for the TRANSPORT_PRIORITY value.
short Priority
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TEXT("TCP_Factory")

◆ thread_priority()

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_DEBUG, ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OpenDDS::DCPS::PriorityMapper::priority(), TheServiceParticipant, and value.

Referenced by OpenDDS::DCPS::TransportSendStrategy::TransportSendStrategy().

51 {
52  static const int thread_min = TheServiceParticipant->priority_min();
53  static const int thread_max = TheServiceParticipant->priority_max();
54  static const int direction = (thread_max < thread_min)? -1: 1;
55  static const int range = direction * (thread_max - thread_min);
56 
57  short value = thread_min + direction * this->priority();
58 
59  if (this->priority() < 0) {
60  value = thread_min;
61  }
62 
63  if (this->priority() > range) {
64  value = thread_max;
65  }
66 
68  ACE_DEBUG((LM_DEBUG,
69  ACE_TEXT("(%P|%t) DirectPriorityMapper:thread_priority() - ")
70  ACE_TEXT("mapped TRANSPORT_PRIORITY value %d ")
71  ACE_TEXT("to thread priority %d.\n"),
72  this->priority(),
73  value));
74  }
75 
76  return value;
77 }
#define ACE_DEBUG(X)
const LogLevel::Value value
Definition: debug.cpp:61
Priority & priority()
Accessors for the TRANSPORT_PRIORITY value.
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TEXT("TCP_Factory")
#define TheServiceParticipant

The documentation for this class was generated from the following files: