DirectPriorityMapper.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "DCPS/debug.h"
00010 #include "dds/DCPS/Service_Participant.h"
00011 
00012 #include "DirectPriorityMapper.h"
00013 
00014 #include <algorithm> // For std::min() and std::max()
00015 
00016 #if !defined (__ACE_INLINE__)
00017 #include "DirectPriorityMapper.inl"
00018 #endif /* __ACE_INLINE__ */
00019 
00020 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 OpenDDS::DCPS::DirectPriorityMapper::~DirectPriorityMapper()
00023 {
00024 }
00025 
00026 short
00027 OpenDDS::DCPS::DirectPriorityMapper::codepoint() const
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 }
00048 
00049 short
00050 OpenDDS::DCPS::DirectPriorityMapper::thread_priority() const
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 }
00078 
00079 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1