smartinspectpython.sipacketqueue

@export
class SIPacketQueue:

Manages a memory size limited queue of packets.

This class is responsible for managing a size limited queue of packets. This functionality is needed by the protocol SIProtocol.IsValidOption feature. The maximum total memory size of the queue can be set with the Backlog property. New packets can be added with the Push method. Packets which are no longer needed can be retrieved and removed from the queue with the Pop method.

Threadsafety:

This class is not guaranteed to be thread-safe.

SIPacketQueue()

Initializes a new instance of the class.

Backlog: int

Gets the Backlog property value.

Represents the total maximum memory size of this queue in bytes.

Each time a new packet is added with the Push method, it will be verified that the total occupied memory size of the queue still falls below the supplied Backlog limit. To satisfy this constraint, old packets are removed from the queue when necessary.

Count: int

Gets the Count property value.

Returns the current amount of packets in this queue.

For each added packet this counter is incremented by one and for each removed packet (either with the Pop method or automatically while resizing the queue) this counter is decremented by one. If the queue is empty, this property returns 0.

def Clear(self) -> None:

Removes all packets from this queue.

Removing all packets of the queue is done by calling the Pop method for each packet in the current queue.

Returns a packet and removes it from the queue.

Returns:

The removed packet or null if the queue does not contain any packets.

If the queue is not empty, this method removes the oldest packet from the queue (also known as FIFO) and returns it. The total size of the queue is decremented by the size of the returned packet (plus some internal management overhead).

def Push(self, packet: smartinspectpython.sipacket.SIPacket) -> None:

Adds a new packet to the queue.

Arguments:
  • packet (SIPacket): The packet to add.

This method adds the supplied packet to the queue. The size of the queue is incremented by the size of the supplied packet (plus some internal management overhead). If the total occupied memory size of this queue exceeds the Backlog limit after adding the new packet, then already added packets will be removed from this queue until the Backlog size limit is reached again.