smartinspectpython.sischedulerqueue

@export
class SISchedulerQueue:

Manages a queue of scheduler commands.

This class is responsible for managing a queue of scheduler commands. This functionality is needed by the SIProtocol.IsValidOption and the SIScheduler class. New commands can be added with the Enqueue method. Commands can be dequeued with Dequeue. This queue does not have a maximum size or count.

Threadsafety:

This class is not guaranteed to be thread-safe.

SISchedulerQueue()

Initializes a new instance of the class.

OVERHEAD: int = 24
Count: int

Returns the current amount of scheduler commands in this queue.

For each added scheduler command this counter is incremented by one and for each removed command (with Dequeue) this counter is decremented by one. If the queue is empty, this property returns 0.

Size: int

Returns the current size of this queue in bytes.

For each added scheduler command this counter is incremented by the size of the command (plus some internal management overhead) and for each removed command (with Dequeue) this counter is then decremented again. If the queue is empty, this property returns 0.

def Clear(self) -> None:

Removes all scheduler commands from this queue.

Removing all scheduler commands of the queue is done by calling the Dequeue method for each command in the current queue.

Returns a scheduler command and removes it from the queue.

Returns:

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

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

def Enqueue( self, command: smartinspectpython.sischedulercommand.SISchedulerCommand) -> None:

Adds a new scheduler command to the queue.

Arguments:
  • command (SISchedulerCommand): The command to add.

This method adds the supplied scheduler command to the queue. The Size of the queue is incremented by the size of the supplied command (plus some internal management overhead). This queue does not have a maximum size or count.

def Trim(self, size: int) -> bool:

Tries to skip and remove scheduler commands from this queue.

Arguments:
  • size (int): The minimum amount of bytes to remove from this queue.
Returns:

True if enough scheduler commands could be removed and false otherwise.

This method removes the next WritePacket scheduler commands from this queue until the specified minimum amount of bytes has been removed. Administrative scheduler commands (connect, disconnect or dispatch) are not removed. If the queue is currently empty or does not contain enough WritePacket commands to achieve the specified minimum amount of bytes, this method returns false.