magicring

package
v0.0.0-...-570722c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) Next

func (rb *RingBuffer) Next(nBytes int) ([]byte, error)

func (*RingBuffer) Peek

func (rb *RingBuffer) Peek(bytesToPeak int) []byte

func (*RingBuffer) Read

func (rb *RingBuffer) Read(buffer []byte) (int, error)

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) Write

func (rb *RingBuffer) Write(buffer []byte) (int, error)

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL