-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
This is a proposal for a generalized buffer class that operates as follows:
- When
add_message(message)
is called, the new message is merely appended to adeque
- Synchronization between the
deque
and a circular buffer occurs...- Upon every
add_message
`if self._update_strategy == "immediate" - Upon some
add_message
callselif self._update_strategy == "threshold" and len(q) > threshold
- Upon
get_data
if self._update_strategy == "on_demand"
- Upon every
- When
get_data(...)
is called, it may synchronize the buffers (see previous point) then it will return a message with the requested data.- The data may be a view of the buffer if the requested interval was contiguous
Compared to a deque-only buffer, this has more efficient reads and minimal copies, especially when reads are less frequent than inserts or reads are likely to have overlaps.
Compared to a circular-only buffer, this has faster insertions.
Metadata
Metadata
Assignees
Labels
No labels