OpenDDS  Snapshot(2023/04/28-20:55)
DirectPriorityMapper.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "DCPS/DdsDcps_pch.h"
9 #include "DCPS/debug.h"
11 
12 #include "DirectPriorityMapper.h"
13 
14 #include <algorithm> // For std::min() and std::max()
15 
16 #if !defined (__ACE_INLINE__)
17 #include "DirectPriorityMapper.inl"
18 #endif /* __ACE_INLINE__ */
19 
21 
23 {
24 }
25 
26 short
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 
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 }
48 
49 short
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 
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 }
78 
#define ACE_DEBUG(X)
const LogLevel::Value value
Definition: debug.cpp:61
virtual short codepoint() const
Access the mapped DiffServ codepoint value.
virtual short thread_priority() const
Access the mapped thread priority value.
LM_DEBUG
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_CDR::Long Priority
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define TheServiceParticipant
Priority & priority()
Accessors for the TRANSPORT_PRIORITY value.