Sirikata
Public Types | Public Member Functions | Private Types | Private Attributes
Sirikata::QueueRouterElement< PacketType > Class Template Reference

A queue router element which buffers packets. More...

#include <QueueRouterElement.hpp>

Inheritance diagram for Sirikata::QueueRouterElement< PacketType >:
Collaboration diagram for Sirikata::QueueRouterElement< PacketType >:

List of all members.

Public Types

typedef std::tr1::function
< uint32(PacketType *) 
SizeFunctor )

Public Member Functions

 QueueRouterElement (uint32 max_size, SizeFunctor sizefunc)
 ~QueueRouterElement ()
bool empty ()
bool push (PacketType *pkt)
virtual bool push (uint32 port, PacketType *pkt)
 Push a packet to this element on the given port.
bool push (PacketType *pkt, bool force)
bool push (uint32 port, PacketType *pkt, bool force)
bool wentNonEmpty ()
 If a push causes the queue to go from empty to non-empty, this will return true.
PacketType * pull ()
virtual PacketType * pull (uint32 port)
 Pull a packet from the element on the specified port.

Private Types

typedef boost::mutex mutex
typedef boost::unique_lock< mutexunique_lock
typedef std::queue< PacketType * > PacketQueue

Private Attributes

boost::mutex mMutex
PacketQueue mPackets
const SizeFunctor mSizeFunctor
uint32 mMaxSize
Sirikata::AtomicValue< uint32 > mSize
bool mWentNonEmpty

Detailed Description

template<typename PacketType>
class Sirikata::QueueRouterElement< PacketType >

A queue router element which buffers packets.

The size of the queue and a method for determining the size of a packet is provided. If the maximum size would be violated, drops the last item in the queue. Only has a single input and output.


Member Typedef Documentation

template<typename PacketType>
typedef boost::mutex Sirikata::QueueRouterElement< PacketType >::mutex [private]
template<typename PacketType>
typedef std::queue<PacketType*> Sirikata::QueueRouterElement< PacketType >::PacketQueue [private]
template<typename PacketType>
typedef std::tr1::function<uint32(PacketType*) Sirikata::QueueRouterElement< PacketType >::SizeFunctor)
template<typename PacketType>
typedef boost::unique_lock<mutex> Sirikata::QueueRouterElement< PacketType >::unique_lock [private]

Constructor & Destructor Documentation

template<typename PacketType>
Sirikata::QueueRouterElement< PacketType >::QueueRouterElement ( uint32  max_size,
SizeFunctor  sizefunc 
) [inline]
template<typename PacketType>
Sirikata::QueueRouterElement< PacketType >::~QueueRouterElement ( ) [inline]

Member Function Documentation

template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::empty ( ) [inline]
template<typename PacketType>
virtual PacketType* Sirikata::QueueRouterElement< PacketType >::pull ( uint32  port) [inline, virtual]

Pull a packet from the element on the specified port.

Parameters:
portthe port to request the packet from
Returns:
a packet, or NULL if one cannot be pulled currently

Implements Sirikata::UpstreamElementBase< PacketType >.

template<typename PacketType>
PacketType* Sirikata::QueueRouterElement< PacketType >::pull ( ) [inline]
template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::push ( PacketType *  pkt,
bool  force 
) [inline]
template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::push ( uint32  port,
PacketType *  pkt,
bool  force 
) [inline]
template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::push ( PacketType *  pkt) [inline]
template<typename PacketType>
virtual bool Sirikata::QueueRouterElement< PacketType >::push ( uint32  port,
PacketType *  pkt 
) [inline, virtual]

Push a packet to this element on the given port.

Parameters:
portthe port to push the packet to
pktthe packet to push

Implements Sirikata::DownstreamElementBase< PacketType >.

template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::wentNonEmpty ( ) [inline]

If a push causes the queue to go from empty to non-empty, this will return true.

Calling this resets the value.


Member Data Documentation

template<typename PacketType>
uint32 Sirikata::QueueRouterElement< PacketType >::mMaxSize [private]
template<typename PacketType>
boost::mutex Sirikata::QueueRouterElement< PacketType >::mMutex [private]
template<typename PacketType>
PacketQueue Sirikata::QueueRouterElement< PacketType >::mPackets [private]
template<typename PacketType>
Sirikata::AtomicValue<uint32> Sirikata::QueueRouterElement< PacketType >::mSize [private]
template<typename PacketType>
const SizeFunctor Sirikata::QueueRouterElement< PacketType >::mSizeFunctor [private]
template<typename PacketType>
bool Sirikata::QueueRouterElement< PacketType >::mWentNonEmpty [private]

The documentation for this class was generated from the following file: