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::DCPS::DirectPriorityMapper::~DirectPriorityMapper()
00021 {
00022 }
00023 
00024 short
00025 OpenDDS::DCPS::DirectPriorityMapper::codepoint() const
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 }
00046 
00047 short
00048 OpenDDS::DCPS::DirectPriorityMapper::thread_priority() const
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 }

Generated on Fri Feb 12 20:05:22 2016 for OpenDDS by  doxygen 1.4.7