ring

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 4 Imported by: 0

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 represents a circular array of data items. It is suitable for (single/multiple) consumers (single/multiple) producers data transfer.

func NewBuffer

func NewBuffer(length int) *Buffer

NewBuffer returns an initialized ring buffer.

func (*Buffer) Close

func (r *Buffer) Close()

Close will close the Buffer.

func (*Buffer) Closed

func (r *Buffer) Closed() bool

Closed checks if buffer is closed.

func (*Buffer) GetAll

func (r *Buffer) GetAll() ([][]byte, bool)

GetAll gets all items in a buffer.

func (*Buffer) Has

func (r *Buffer) Has(item []byte) bool

Has checks if item exists.

func (*Buffer) Put

func (r *Buffer) Put(item []byte) bool

Put an item on the ring buffer.

type Consumer

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

Consumer represents an entity which can read items from a ring buffer. It maintains its own read index, and cache.

func NewConsumer

func NewConsumer(ring *Buffer, callback func(items [][]byte, w io.WriteCloser) bool, w io.WriteCloser) *Consumer

NewConsumer returns a Consumer, which can read from the passed Buffer.

Jump to

Keyboard shortcuts

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