ProtocolByteAccumulator class

Single reusable buffer for incremental protocol framing.

Incoming stream chunks are appended once. take transfers ownership of the frame bytes (zero-copy view of the prior backing store) so callers that retain the frame (including lazy UTF-8 string cells) keep a live buffer. The accumulator allocates a fresh backing for later adds, preferring a small free-list of fixed-capacity buffers to cut GC under sustained streaming.

Constructors

ProtocolByteAccumulator({int initialCapacity = 64 * 1024})

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Uint8List chunk) → void
drop(int count) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek(int count) Uint8List
take(int count) Uint8List
Returns a view of the leading count bytes and releases them from this accumulator. The returned list keeps the previous backing store alive.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

pooledBackingCount int
Number of buffers currently held in free-lists (for tests).
no setter
pooledDefaultBackingCount int
Number of 64 KiB buffers in the default free-list (for tests).
no setter
pooledLargeBackingCount int
Number of 1 MiB buffers in the large free-list (for tests).
no setter

Static Methods

clearPoolForTest() → void
Clears free-lists (for tests).
offerDefaultBacking(Uint8List buffer) → void
Alias kept for callers/tests that recycle default-capacity frames.
offerPooledBacking(Uint8List buffer) → void
Offers a fixed-capacity empty buffer back to the matching free-list.