forest-net
an overlay networks for large-scale virtual worlds
|
Maintains a set of packets with selected header fields and a separate set of buffers. More...
#include <PacketStoreTs.h>
Public Member Functions | |
PacketStoreTs (int=10000) | |
Constructor allocates space and initializes free list. More... | |
Packet & | getPacket (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 | |
Packet * | pkt |
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 | |
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.
forest::PacketStoreTs::PacketStoreTs | ( | int | N1 = 10000 ) |
Constructor allocates space and initializes free list.
N1 | is number of packets to allocate space for |
Definition at line 16 of file PacketStoreTs.cpp.
pktx forest::PacketStoreTs::alloc | ( | ) |
Allocate a new packet and buffer.
Definition at line 37 of file PacketStoreTs.cpp.
void forest::PacketStoreTs::free | ( | pktx | px) |
Release the storage used by a packet.
Also releases the associated buffer, if no clones are using it.
p | is the packet number of the packet to be released |
Definition at line 59 of file PacketStoreTs.cpp.
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.
Definition at line 73 of file PacketStoreTs.cpp.
|
inline |
Get reference to packet header.
px | is a packet number |
Definition at line 71 of file PacketStoreTs.h.