Segment

A segment of a buffer.

Each segment in a buffer is a doubly-linked list node referencing the following and preceding segments in the buffer.

Each segment in the pool is a singly-linked list node referencing the rest of segments in the pool.

The underlying byte arrays of segments may be shared between buffers and byte strings. When a segment's byte array is shared the segment may not be recycled, nor may its byte data be changed. The lone exception is that the owner segment is allowed to append to the segment, writing data at limit and beyond. There is a single owning segment for each byte array. Positions, limits, prev, and next references are not shared.

Properties

Link copied to clipboard

The number of bytes that could be written into this segment.

Link copied to clipboard
val size: Int

The number of readable bytes contained in this segment.