spin

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 4 Imported by: 1

README

spin

Ring buffer implementation in go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is the ring buffer implementation.

func NewBuffer added in v0.3.0

func NewBuffer() *Buffer

NewBuffer creates a new ring buffer.

func (*Buffer) Close

func (b *Buffer) Close() error

Close closes the buffer.

func (*Buffer) Iterate

func (b *Buffer) Iterate(f func(p []byte) (int, bool, error)) (int64, error)

Iterate implements iterator over available data. It makes all the available data to the iterator, then it should say how many bytes has been used and if iterator is interested in receiving more data.

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (int, error)

Read reads bytes from the buffer.

func (*Buffer) ReadByte

func (b *Buffer) ReadByte() (byte, error)

ReadByte reads one byte from the buffer.

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(r io.Reader) (int64, error)

ReadFrom copies the content of the provided reader to the ring buffer.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (int, error)

Write writes bytes to the ring buffer.

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(v byte) error

WriteByte writes one byte to the buffer.

func (*Buffer) WriteTo

func (b *Buffer) WriteTo(w io.Writer) (int64, error)

WriteTo copies the content of the ring buffer to the provided writer.

type Queue added in v0.3.0

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue is the ring queue implementation.

func NewQueue added in v0.3.0

func NewQueue[T any]() *Queue[T]

NewQueue creates a new ring queue.

func (*Queue[T]) Close added in v0.3.0

func (q *Queue[T]) Close()

Close closes the queue.

func (*Queue[T]) Dequeue added in v0.3.0

func (q *Queue[T]) Dequeue() (T, error)

Dequeue returns item from the queue.

func (*Queue[T]) Enqueue added in v0.3.0

func (q *Queue[T]) Enqueue(v T) error

Enqueue adds item to the queue.

Jump to

Keyboard shortcuts

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