INNER CODE UNIT · Python
UniqueQueue
bkbilly/lnxlink · lnxlink/__main__.py:24
class UniqueQueue:
"""
A queue that coalesces named items by default, with a maximum size limit.
Non-coalescing items keep their original names when yielded.
When full, the oldest item is discarded to make room.
"""
def __init__(self, max_size=200):
"""Initializes the UniqueQueue"""
self.queue = OrderedDict()
self.max_size = max_size
self._lock = threading.Lock()
self._condition = threading.Condition(self._lock)
self._sequence = 0
def __repr__(self):
"""Returns a string representation of the queue."""
return f"<{self.__class__.__name__} queue: {repr(self.queue)}>"