LCOV - code coverage report
Current view: top level - DCPS/transport/framework - DirectPriorityMapper.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 20 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 4 0.0 %

          Line data    Source code
       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"
      10             : #include "dds/DCPS/Service_Participant.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             : 
      20             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      21             : 
      22           0 : OpenDDS::DCPS::DirectPriorityMapper::~DirectPriorityMapper()
      23             : {
      24           0 : }
      25             : 
      26             : short
      27           0 : OpenDDS::DCPS::DirectPriorityMapper::codepoint() const
      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           0 :   short value = std::min(dscp_max, std::max(dscp_min, this->priority()));
      36             : 
      37           0 :   if (OpenDDS::DCPS::DCPS_debug_level > 4) {
      38           0 :     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           0 :   return value;
      47             : }
      48             : 
      49             : short
      50           0 : OpenDDS::DCPS::DirectPriorityMapper::thread_priority() const
      51             : {
      52           0 :   static const int thread_min = TheServiceParticipant->priority_min();
      53           0 :   static const int thread_max = TheServiceParticipant->priority_max();
      54           0 :   static const int direction  = (thread_max < thread_min)? -1: 1;
      55           0 :   static const int range      = direction * (thread_max - thread_min);
      56             : 
      57           0 :   short value = thread_min + direction * this->priority();
      58             : 
      59           0 :   if (this->priority() < 0) {
      60           0 :     value = thread_min;
      61             :   }
      62             : 
      63           0 :   if (this->priority() > range) {
      64           0 :     value = thread_max;
      65             :   }
      66             : 
      67           0 :   if (OpenDDS::DCPS::DCPS_debug_level > 4) {
      68           0 :     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           0 :   return value;
      77             : }
      78             : 
      79             : OPENDDS_END_VERSIONED_NAMESPACE_DECL

Generated by: LCOV version 1.16