forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
forest::PacketStoreTs Class Reference

Maintains a set of packets with selected header fields and a separate set of buffers. More...

#include <PacketStoreTs.h>

Collaboration diagram for forest::PacketStoreTs:

Public Member Functions

 PacketStoreTs (int=10000)
 Constructor allocates space and initializes free list. More...
 
PacketgetPacket (pktx) const
 Get reference to packet header. More...
 
pktx alloc ()
 Allocate a new packet and buffer. More...
 
void free (pktx)
 Release the storage used by a packet. More...
 
pktx fullCopy (pktx)
 Allocate a new packet that with the same content as px. More...
 
void unpack (pktx)
 
void pack (pktx)
 

Private Attributes

int N
 number of packets we have room for
 
int n
 number of packets in use
 
Packetpkt
 pkt[i] = packet i
 
buffer_t * buff
 buff[i] = buffer for packet i
 
List * freePkts
 list of free packets/buffers
 
pthread_mutex_t lock
 used during allocate/free
 

Detailed Description

Maintains a set of packets with selected header fields and a separate set of buffers.

For use in multi-threaded contexts. The object is locked when allocating, de-allocating, or copying a packet. No locking is done for other methods. This is fine so long as no two threads attempt to access the same packet concurrently. Also note that this version of packet store does not support multiple packets that reference the same buffer, as it is intended for use with end systems, not routers.

Definition at line 30 of file PacketStoreTs.h.

Constructor & Destructor Documentation

forest::PacketStoreTs::PacketStoreTs ( int  N1 = 10000)

Constructor allocates space and initializes free list.

Parameters
N1is number of packets to allocate space for

Definition at line 16 of file PacketStoreTs.cpp.

Member Function Documentation

pktx forest::PacketStoreTs::alloc ( )

Allocate a new packet and buffer.

Returns
the packet number or 0, if no more packets available

Definition at line 37 of file PacketStoreTs.cpp.

Here is the caller graph for this function:

void forest::PacketStoreTs::free ( pktx  px)

Release the storage used by a packet.

Also releases the associated buffer, if no clones are using it.

Parameters
pis the packet number of the packet to be released

Definition at line 59 of file PacketStoreTs.cpp.

Here is the caller graph for this function:

pktx forest::PacketStoreTs::fullCopy ( pktx  px)

Allocate a new packet that with the same content as px.

A new buffer is allocated for this packet.

Returns
the index of the new packet.

Definition at line 73 of file PacketStoreTs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Packet & forest::PacketStoreTs::getPacket ( pktx  px) const
inline

Get reference to packet header.

Parameters
pxis a packet number
Returns
a reference to the packet header for p

Definition at line 71 of file PacketStoreTs.h.

Here is the caller graph for this function:


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