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_);
113 queue_.push_front(
packet);
128 std::lock_guard<std::mutex> lock(*mutex_);
130 if (queue_.empty()) {
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_;
read_packet FORK if not parent: break YIELD answer=DNSLookup(packet, this) response=DNSAnswer(answer) YIELD send(response) At each "YIELD" point, the coroutine initiates an asynchronous operation, then pauses and turns over control to some other task on the ASIO service queue. When the operation completes, the coroutine resumes. The DNSLookup and DNSAnswer define callback methods used by a DNS Server to communicate with the module that called it. They are abstract-only classes whose concrete implementations are supplied by the calling module. The DNSLookup callback always runs asynchronously. Concrete implementations must be sure to call the server 's "resume" method when it is finished. In an authoritative server, the DNSLookup implementation would examine the query, look up the answer, then call "resume"(See the diagram in doc/auth_process.jpg). In a recursive server, the DNSLookup implementation would initiate a DNSQuery, which in turn would be responsible for calling the server 's "resume" method(See the diagram in doc/recursive_process.jpg). A DNSQuery object is intended to handle resolution of a query over the network when the local authoritative data sources or cache are not sufficient. The plan is that it will make use of subsidiary DNSFetch calls to get data from particular authoritative servers, and when it has gotten a complete answer, it calls "resume". In current form, however, DNSQuery is much simpler packet
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())
PacketQueueRing4(const std::string &queue_type, size_t capacity)
Constructor.
virtual ~PacketQueueRing4()
virtual Destructor
PacketQueueRing6(const std::string &queue_type, size_t capacity)
Constructor.
virtual ~PacketQueueRing6()
virtual Destructor
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.
virtual data::ElementPtr getInfo() const
Fetches operational information about the current state of the queue.
PacketQueue(const std::string &queue_type)
Constructor.
#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.