IOPacketQueue



Member Functions

dequeue

public:

struct mbuf * dequeue();

Remove a single packet from the head of the queue.

Result: The dequeued packet. A NULL is returned if the queue is empty.

dequeueAll

public:

struct mbuf * dequeueAll();

Removes all packets from the queue and return the head of the packet chain.

Result: The head of the dequeued packet chain.

enqueue

public:

UInt32 enqueue(struct mbuf * m);

Add a packet (or a packet chain) to the tail of the queue.

Parameters

NameDescription
mA single packet, or a packet chain, to be added to the tail of the queue.
Result: The number of packets dropped due to over-capacity.

flush

public:

UInt32 flush();

Removes all packets from the queue and put them back to the free buffer pool. The size of the queue becomes zero after the call.

Result: The number of packets freed.

free

private:

virtual void free();

Frees the IOPacketQueue instance. All packets in the queue are released back to the free buffer pool.


freePacketChain

public:

static UInt32 freePacketChain(struct mbuf * m);

This method frees a mbuf chain linked through the mbuf's nextpkt pointers.

Parameters

NameDescription
mThe mbuf at the start of the mbuf chain.
Result: The number of mbufs freed.

getCapacity

public:

UInt32 getCapacity() const;

Get the capacity of the queue.

Result: The current queue capacity.

getPeakSize

public:

UInt32 getPeakSize(bool reset = false);

The queue contains a counter that registers the peak size of the queue. This method returns the value in the counter, and optionally resets the counter to zero.

Parameters

NameDescription
resetReset the peak size counter to zero if true.
Result: The peak size count.

getSize

public:

UInt32 getSize() const;

Get the size of the queue.

Result: The number of packets currently held in the queue.

initWithCapacity

public:

virtual bool initWithCapacity(UInt32 capacity = IOPQDefaultCapacity);

Initialize an IOPacketQueue instance.

Parameters

NameDescription
capacityThe initial capacity of the queue.
Result: true if initialized successfully, false otherwise.

lockDequeue

public:

struct mbuf * lockDequeue();

Same as dequeue(). A spinlock lock is held while the queue is being accessed.

Result: See dequeue().

lockDequeueAll

public:

struct mbuf * lockDequeueAll();

Same as dequeueAll(). A spinlock lock is held while the queue is being accessed.

Result: See dequeueAll().

lockEnqueue

public:

UInt32 lockEnqueue(struct mbuf * m);

Same as enqueue(). A spinlock lock is held while the queue is being accessed.

Parameters

NameDescription
Seeenqueue().
Result: See enqueue().

lockFlush

public:

UInt32 lockFlush();

Same as flush(). A spinlock lock is held while the queue is being accessed.

Result: See flush().

lockPrepend

public:

void lockPrepend(struct mbuf * m);

Same as prepend(). A spinlock lock is held while the queue is being accessed.

Parameters

NameDescription
Seeprepend().

peek

public:

const struct mbuf * peek() const;

Peek at the head of the queue without dequeueing the packet. Subsequent calls to peek() or dequeue() will return the same packet. The caller must not modify the packet.

Result: The packet at the head of the queue.

prepend

public:

void prepend(struct mbuf * m);

Add a packet (or a packet chain) to the head of the queue. Unlike enqueue(), the capacity is not checked, and the input packet is never dropped.

Parameters

NameDescription
mA single packet, or packet chain, to be added to the head of the queue.

setCapacity

public:

bool setCapacity(UInt32 capacity);

Adjust the capacity of the queue. If the capacity is set to a value that is smaller than its current size, then the queue will drop incoming packets, but existing packets in the queue will remain intact.

Parameters

NameDescription
capacityThe new capacity.
Result: true if the new capacity was accepted, false otherwise.

withCapacity

public:

static IOPacketQueue * withCapacity(UInt32 capacity = IOPQDefaultCapacity);

Factory method that will construct and initialize an IOPacketQueue instance.

Parameters

NameDescription
capacityThe initial capacity of the queue.
Result: An IOPacketQueue instance upon success, or 0 otherwise.

Member Data

IOPQDefaultCapacity

private:
 static const UInt32 IOPQDefaultCapacity = 100;

Specifies the default capacity of the queue (number of packets that the queue can hold). Once the size of the queue grows to its capacity, the queue will begin to drop incoming packets. This capacity can be overridden by specifying the desired capacity when the queue is initialized, or the setCapacity() method can be called to adjust the queue's capacity.


© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)