2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief REDQueue inline non-template implementation */
17 //#include "REDQueue.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 prefix_ bool senf::emu::REDQueue::v_enqueue(senf::Packet const & packet, bool force)
25 if (!force and (queueSize_ > lowThresh_)) {
26 if ( (boost::uint32_t(rand()) % (queueLimit_ - lowThresh_ + 1)) <= (queueSize_ - lowThresh_) ) {
27 packetsDroppedTotal_++;
28 return false; // no additional packet added to queue
32 queue_.emplace(packet);
33 queueSize_ += packet.size();
37 prefix_ void senf::emu::REDQueue::v_pop()
39 if (SENF_LIKELY(frontPktSize_ > 0)) {
40 queueSize_ -= frontPktSize_;
46 prefix_ unsigned senf::emu::REDQueue::v_peek(unsigned maxSize)
49 if (!queue_.empty() and (queue_.front().size() <= maxSize))
50 return frontPktSize_ = queue_.front().size();
54 prefix_ senf::Packet const & senf::emu::REDQueue::v_front()
57 return queue_.front();
60 prefix_ bool senf::emu::REDQueue::v_empty()
63 return queue_.empty();
66 prefix_ unsigned senf::emu::REDQueue::v_size()
72 prefix_ void senf::emu::REDQueue::incrDropped()
74 packetsDroppedTotal_++;
77 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 // c-file-style: "senf"
86 // indent-tabs-mode: nil
87 // ispell-local-dictionary: "american"
88 // compile-command: "scons -u test"