Add RTMLib CUDA backends and staged timing
This commit is contained in:
@@ -41,6 +41,8 @@ def inverse_letterbox(points: np.ndarray, scale: float, pad_x: float, pad_y: flo
|
||||
class LatestQueue:
|
||||
def __init__(self) -> None:
|
||||
self._q: queue.Queue[Any] = queue.Queue(maxsize=1)
|
||||
self._dropped = 0
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def put(self, item: Any) -> None:
|
||||
try:
|
||||
@@ -48,12 +50,17 @@ class LatestQueue:
|
||||
except queue.Full:
|
||||
try:
|
||||
self._q.get_nowait()
|
||||
with self._lock:
|
||||
self._dropped += 1
|
||||
except queue.Empty:
|
||||
pass
|
||||
self._q.put_nowait(item)
|
||||
|
||||
def get(self, timeout: float | None = None) -> Any:
|
||||
return self._q.get(timeout=timeout)
|
||||
def get(self, timeout: float | None = None) -> tuple[Any, int]:
|
||||
item = self._q.get(timeout=timeout)
|
||||
with self._lock:
|
||||
dropped, self._dropped = self._dropped, 0
|
||||
return item, dropped
|
||||
|
||||
def qsize(self) -> int:
|
||||
return self._q.qsize()
|
||||
@@ -74,7 +81,7 @@ class BroadcastHub:
|
||||
with self._lock:
|
||||
self._clients.discard(q)
|
||||
|
||||
def publish_on_loop(self, loop: asyncio.AbstractEventLoop, message: dict) -> None:
|
||||
def publish_on_loop(self, loop: asyncio.AbstractEventLoop, message: str) -> None:
|
||||
def publish() -> None:
|
||||
with self._lock:
|
||||
clients = list(self._clients)
|
||||
|
||||
Reference in New Issue
Block a user