7#ifndef PACKET_QUEUE_RING_H
8#define PACKET_QUEUE_RING_H
12#include <boost/circular_buffer.hpp>
13#include <boost/scoped_ptr.hpp>
25template<
typename PacketTypePtr>
38 queue_.set_capacity(capacity);
39 mutex_.reset(
new std::mutex);
109 std::lock_guard<std::mutex> lock(*mutex_);
111 queue_.push_back(packet);
113 queue_.push_front(packet);
127 PacketTypePtr packet;
128 std::lock_guard<std::mutex> lock(*mutex_);
130 if (queue_.empty()) {
135 packet = queue_.front();
138 packet = queue_.back();
156 PacketTypePtr packet;
157 if (!queue_.empty()) {
166 std::lock_guard<std::mutex> lock(*mutex_);
167 return (queue_.empty());
172 return (queue_.capacity());
184 <<
" is invalid. It must be at least "
189 queue_.set_capacity(capacity);
194 return (queue_.size());
213 boost::circular_buffer<PacketTypePtr> queue_;
216 boost::scoped_ptr<std::mutex> mutex_;
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static ElementPtr create(const Position &pos=ZERO_POSITION())
DHCPv4 packet queue buffer implementation.
PacketQueueRing4(const std::string &queue_type, size_t capacity)
Constructor.
virtual ~PacketQueueRing4()
virtual Destructor
DHCPv6 packet queue buffer implementation.
PacketQueueRing6(const std::string &queue_type, size_t capacity)
Constructor.
virtual ~PacketQueueRing6()
virtual Destructor
Provides a ring-buffer implementation of the PacketQueue interface.
virtual void pushPacket(PacketTypePtr &packet, const QueueEnd &to=QueueEnd::BACK)
Pushes a packet onto the queue.
virtual void enqueuePacket(PacketTypePtr packet, const SocketInfo &source)
Adds a packet to the queue.
virtual size_t getSize() const
Returns the current number of packets in the buffer.
virtual void setCapacity(size_t capacity)
Sets the maximum number of packets allowed in the buffer.
virtual data::ElementPtr getInfo() const
Fetches pertinent information.
virtual size_t getCapacity() const
Returns the maximum number of packets allowed in the buffer.
virtual int eatPackets(const QueueEnd &)
Discards packets from one end of the queue.
virtual bool empty() const
Returns True if the queue is empty.
virtual bool shouldDropPacket(PacketTypePtr, const SocketInfo &)
Determines if a packet should be discarded.
virtual const PacketTypePtr peek(const QueueEnd &from=QueueEnd::FRONT) const
Gets the packet currently at one end of the queue.
virtual ~PacketQueueRing()
virtual Destructor
virtual PacketTypePtr dequeuePacket()
Dequeues the next packet from the queue.
virtual PacketTypePtr popPacket(const QueueEnd &from=QueueEnd::FRONT)
Pops a packet from the queue.
virtual void clear()
Discards all packets currently in the buffer.
PacketQueueRing(const std::string &queue_type, size_t capacity)
Constructor.
static const size_t MIN_RING_CAPACITY
Minimum queue capacity permitted.
Interface for managing a queue of inbound DHCP packets.
virtual data::ElementPtr getInfo() const
Fetches operational information about the current state of the queue.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Element > ElementPtr
QueueEnd
Enumerates choices between the two ends of the queue.
Defines the logger used by the top-level component of kea-lfc.
Holds information about socket.