def setLatencyThreshold(self, usec): self._queueMutex.acquire() try: self._thresholdLatency = utils.usec_to_sec(usec) if self._latencyExceeded(): # Wake up the monitor thread to do a push self._executeThreadedFlush() elif self._queue: # Schedule a check at the new latency threshold self._port._scheduleCheck(self._startTime + self._thresholdLatency) finally: self._queueMutex.release()
def __init__(self, port, maxBursts, thresholdBytes, thresholdLatency, streamID=None): self._port = port self._streamID = streamID # Policy settings self._maxBursts = maxBursts self._thresholdBytes = thresholdBytes self._thresholdLatency = utils.usec_to_sec(thresholdLatency) # Queue management self._queue = [] self._queueMutex = threading.Lock() self._queuedBytes = 0 self._startTime = None