smartinspectpython.sischeduler
Module: sischeduler.py
Revision History
Date | Version | Description |
---|---|---|
2023/05/30 | 3.0.0.0 | Initial Version. |
Responsible for scheduling protocol operations and executing them asynchronously in a different thread of control.
This class is used by the SIProtocol.IsValidOption to asynchronously execute protocol operations. New commands can be scheduled for execution with the Schedule method. The scheduler can be started and stopped with the Start and Stop methods. The scheduler uses a size limited queue to buffer scheduler commands. The maximum size of this queue can be set with the Threshold property. To influence the behavior of the scheduler if new commands are enqueued and the queue is currently considered full, you can specify the Throttle mode.
Threadsafety:
This class is guaranteed to be thread-safe.
Initializes a new instance of the class.
Arguments:
- protocol (SIProtocol): The protocol object on which to execute the actual operations like connect, disconnect, write or dispatch.
Gets the Threshold property value.
Represents the maximum size of the scheduler command queue.
To influence the behavior of the scheduler if new commands are enqueued and the queue is currently considered full, you can specify the Throttle mode.
Gets the Throttle property value.
Specifies if the scheduler should automatically throttle threads that enqueue new scheduler commands.
If this property is true and the queue is considered full when enqueuing new commands, the enqueuing thread is automatically throttled until there is room in the queue for the new command. In non-throttle mode, the thread is not blocked but older commands are removed from the queue.
Removes all scheduler commands from this scheduler.
This method clears the current queue of scheduler commands. If the Stop method is called after calling Clear and no new commands are stored between these two calls, the internal scheduler thread will exit as soon as possible (after the current command, if any, has been processed).
Schedules a new command for asynchronous execution.
Arguments:
- command (SISchedulerCommand): The command to schedule.
Returns:
True if the command could be scheduled for asynchronous execution and false otherwise.
This method adds the passed command to the internal queue of scheduler commands. The command is eventually executed by the internal scheduler thread. This method can block the caller if the scheduler operates in Throttle mode and the internal queue is currently considered full (see Threshold).
Starts this scheduler and the internal scheduler threadtask.
This method must be called before scheduling new commands with the Schedule method. Call Stop to stop the internal thread when the scheduler is no longer needed. Note that this method starts the internal scheduler thread only once. This means that subsequent calls to this method have no effect.
Stops this scheduler and the internal scheduler threadtask.
This is the matching method for Start. After calling this method, new commands will no longer be accepted by Schedule and are ignored. This method blocks until the internal thread has processed the current content of the queue. Call Clear before calling Stop to exit the internal thread as soon as possible.