buffering

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize uint32 = 5000

BufferSize the default size for the Ring Buffer

Variables

This section is empty.

Functions

This section is empty.

Types

type RingBuffer

type RingBuffer struct {
	Size uint32

	Mutex *sync.Mutex
	// contains filtered or unexported fields
}

RingBuffer data structure

func (*RingBuffer) Get

func (r *RingBuffer) Get() *interface{}

Get returns the elements in FIFO manner or nil if buffer is empty.

func (*RingBuffer) PrintDetails

func (r *RingBuffer) PrintDetails()

PrintDetails diplays details for debugging purpose.

func (*RingBuffer) Put

func (r *RingBuffer) Put(inp interface{}) bool

Put adds the item into buffer if there is room in buffer. Returns true if item is buffered otherwise false.

func (*RingBuffer) ReadN

func (r *RingBuffer) ReadN(n uint32) ([]*interface{}, uint32)

ReadN reads the next n available elements in the buffer. Returns elements and number of elements read.

func (*RingBuffer) RemoveN

func (r *RingBuffer) RemoveN(n uint32)

RemoveN removes the first n elements from the buffer.

Jump to

Keyboard shortcuts

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