ringbuffer

package
v0.0.0-...-7a23388 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpRead = iota
	OpWrite
)

Variables

View Source
var RingBufferGuardByteSize = 8 * 1024 * 1024 //8MB
View Source
var RingBufferInitByteSize = 16 * 1024

RingBufferInitByteSize ...

View Source
var RingBufferLimitByteSize = 1024 * 1024

RingBufferLimitByteSize ...

Functions

This section is empty.

Types

type RingBuffer

type RingBuffer struct {
	// contains filtered or unexported fields
}

RingBuffer is a circular buffer

func NewRingBuffer

func NewRingBuffer() *RingBuffer

NewRingBuffer returns a new RingBuffer whose buffer has the given size.

func (*RingBuffer) AlignBytes

func (r *RingBuffer) AlignBytes() []byte

Bytes ...

func (*RingBuffer) Capacity

func (r *RingBuffer) Capacity() int

Capacity ...

func (*RingBuffer) Forward

func (r *RingBuffer) Forward(step, mode int) int

Forward ...

func (*RingBuffer) Free

func (r *RingBuffer) Free() int

Free ...

func (*RingBuffer) Has

func (r *RingBuffer) Has() int

Has ...

func (*RingBuffer) Peek2

func (r *RingBuffer) Peek2() (head, tail []byte)

Peek2 returns the readable bytes as up to two slices. The second slice is non-nil only when the data wraps around the end.

func (*RingBuffer) PeekWrite

func (r *RingBuffer) PeekWrite(length int) []byte

PeekWrite returns a contiguous slice of writable bytes. The returned slice may be smaller than length if it would wrap around the end. After writing n bytes into the returned slice, call Forward(n, OpWrite).

func (*RingBuffer) Read

func (r *RingBuffer) Read(p *[]byte, length int, update bool) int

Read ...

func (*RingBuffer) Reset

func (r *RingBuffer) Reset()

Reset the read pointer and writer pointer to zero.

func (*RingBuffer) Status

func (r *RingBuffer) Status() string

func (*RingBuffer) Truncate

func (r *RingBuffer) Truncate()

Truncate ...

func (*RingBuffer) Update

func (r *RingBuffer) Update(buf []byte)

Bytes ...

func (*RingBuffer) Write

func (r *RingBuffer) Write(p *[]byte, length int, update bool) int

Write ...

Jump to

Keyboard shortcuts

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