Documentation ¶
Index ¶
- Variables
- type RingBuffer
- func (rb *RingBuffer) AdvanceRead(bytesToAdvance int)
- func (rb *RingBuffer) AdvanceWrite(bytesToAdvance int)
- func (rb *RingBuffer) Available() int
- func (rb *RingBuffer) Buffered() int
- func (rb *RingBuffer) Bytes() []byte
- func (rb *RingBuffer) Cap() int
- func (rb *RingBuffer) Discard(bytesToDiscard int) int
- func (rb *RingBuffer) Grow(newCap int)
- func (rb *RingBuffer) GrowIfUnsufficientFreeSpace()
- func (rb *RingBuffer) IsEmpty() bool
- func (rb *RingBuffer) IsFull() bool
- func (rb *RingBuffer) Next(nBytes int) ([]byte, error)
- func (rb *RingBuffer) Peek(bytesToPeak int) []byte
- func (rb *RingBuffer) Read(buffer []byte) (int, error)
- func (rb *RingBuffer) ReadAddress() unsafe.Pointer
- func (rb *RingBuffer) ReadByte() (byte, error)
- func (rb *RingBuffer) ReadFrom(reader io.Reader) (int64, error)
- func (rb *RingBuffer) ReleaseBytes()
- func (rb *RingBuffer) Reset()
- func (rb *RingBuffer) Write(buffer []byte) (int, error)
- func (rb *RingBuffer) WriteAddress() unsafe.Pointer
- func (rb *RingBuffer) WriteByte(c byte) error
- func (rb *RingBuffer) WriteTo(writer io.Writer) (int64, error)
- func (rb *RingBuffer) Zeroes()
Constants ¶
This section is empty.
Variables ¶
var ( DefaultMagicBufferSize = os.Getpagesize() MinRead = 1024 )
Functions ¶
This section is empty.
Types ¶
type RingBuffer ¶
type RingBuffer struct { Size int // contains filtered or unexported fields }
RingBuffer is a circular buffer that implement io.ReaderWriter interface.
func NewMagicBuffer ¶
func NewMagicBuffer(size int) *RingBuffer
New returns a new Buffer whose buffer has the given size.
func (*RingBuffer) AdvanceRead ¶
func (rb *RingBuffer) AdvanceRead(bytesToAdvance int)
func (*RingBuffer) AdvanceWrite ¶
func (rb *RingBuffer) AdvanceWrite(bytesToAdvance int)
func (*RingBuffer) Available ¶
func (rb *RingBuffer) Available() int
Available returns the length of available bytes to write.
func (*RingBuffer) Buffered ¶
func (rb *RingBuffer) Buffered() int
Buffered returns the length of available bytes to read.
func (*RingBuffer) Bytes ¶
func (rb *RingBuffer) Bytes() []byte
Bytes returns all available read bytes. It does not move the read pointer and only copy the available data.
func (*RingBuffer) Cap ¶
func (rb *RingBuffer) Cap() int
Cap returns the size of the underlying buffer.
func (*RingBuffer) Discard ¶
func (rb *RingBuffer) Discard(bytesToDiscard int) int
Discard skips the next n bytes by advancing the read pointer.
func (*RingBuffer) Grow ¶
func (rb *RingBuffer) Grow(newCap int)
func (*RingBuffer) GrowIfUnsufficientFreeSpace ¶
func (rb *RingBuffer) GrowIfUnsufficientFreeSpace()
func (*RingBuffer) IsEmpty ¶
func (rb *RingBuffer) IsEmpty() bool
IsEmpty tells if this ring-buffer is empty.
func (*RingBuffer) IsFull ¶
func (rb *RingBuffer) IsFull() bool
IsFull tells if this ring-buffer is full.
func (*RingBuffer) Peek ¶
func (rb *RingBuffer) Peek(bytesToPeak int) []byte
func (*RingBuffer) ReadAddress ¶
func (rb *RingBuffer) ReadAddress() unsafe.Pointer
func (*RingBuffer) ReadByte ¶
func (rb *RingBuffer) ReadByte() (byte, error)
ReadByte reads and returns the next byte from the input or ErrIsEmpty.
func (*RingBuffer) ReadFrom ¶
func (rb *RingBuffer) ReadFrom(reader io.Reader) (int64, error)
ReadFrom implements io.ReaderFrom.
func (*RingBuffer) ReleaseBytes ¶
func (rb *RingBuffer) ReleaseBytes()
func (*RingBuffer) Reset ¶
func (rb *RingBuffer) Reset()
func (*RingBuffer) WriteAddress ¶
func (rb *RingBuffer) WriteAddress() unsafe.Pointer
func (*RingBuffer) WriteByte ¶
func (rb *RingBuffer) WriteByte(c byte) error
func (*RingBuffer) WriteTo ¶
func (rb *RingBuffer) WriteTo(writer io.Writer) (int64, error)
WriteTo implements io.WriterTo.
func (*RingBuffer) Zeroes ¶
func (rb *RingBuffer) Zeroes()