Added HWM limit option to TransmitBuffer

This commit is contained in:
Mark Qvist 2026-08-27 01:56:43 +02:00
parent 10848b7cff
commit cb9071b478
No known key found for this signature in database

View file

@ -63,8 +63,10 @@ class TransmitBuffer:
# Queue a finalized and complete on-wire frame.
# Executed by producer side only.
def append(self, frame):
def append(self, frame, limit=None):
with self._tail_lock:
if limit is not None and (self._tx_total - self._tx_sent) + len(frame) > limit: return False
# Allocate separate chunks to frames
# larger than the coalescing target.
if len(frame) >= self.COALESCE_TARGET:
@ -91,6 +93,8 @@ class TransmitBuffer:
# sparse traffic does not incur coalescing latency.
self._flush()
return True
def _flush(self):
if self._cur is not None and len(self._cur) > 0:
self._chunks.append((self._cur, self._cur_frames))