Documentation ¶
Overview ¶
Package ringio implements a ring-buffer that is an io.Reader and an io.Writer with fixed-size semantics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bounded ¶
Bounded is an io.Reader and io.Writer that allows writing as many bytes as are given for the capacity before it has to be drained by reading from it.
It is able to safely read and write in parallel, protected by a Mutex.
func New ¶
New returns a bounded ring buffer of the given capacity. If overwrite is true, a full ring buffer will discard unread bytes and overwrite them upon writes.
If overwrite is false, writing more bytes than there is space in the buffer will fail with ErrFull and no bytes will be written.
func (*Bounded) Bytes ¶
Bytes consumes all readable data on the ring buffer and returns a newly-allocated byte slice containing all readable bytes.