ring

package
v1.9.25 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var F, E, W, I, D, T logg.LevelPrinter = logg.GetLogPrinterSet(subsystem)

Functions

This section is empty.

Types

type BufferFloat64

type BufferFloat64 struct {
	Buf    []float64
	Cursor int
	Full   bool
}

func NewBufferFloat64

func NewBufferFloat64(size int) *BufferFloat64

NewBufferFloat64 creates a new ring buffer of float64 values

func (*BufferFloat64) Add

func (b *BufferFloat64) Add(value float64)

Add a new value to the cursor position of the ring buffer

func (*BufferFloat64) ForEach

func (b *BufferFloat64) ForEach(fn func(v float64) error) (e error)

ForEach is an iterator that can be used to process every element in the buffer

func (*BufferFloat64) Get

func (b *BufferFloat64) Get(index int) (out *float64)

Get returns the value at the given index or nil if nothing

func (*BufferFloat64) Len

func (b *BufferFloat64) Len() (length int)

Len returns the length of the buffer, which grows until it fills, after which this will always return the size of the buffer

type BufferUint64

type BufferUint64 struct {
	Buf    []uint64
	Cursor int
	Full   bool
}

func NewBufferUint64

func NewBufferUint64(size int) *BufferUint64

func (*BufferUint64) Add

func (b *BufferUint64) Add(value uint64)

func (*BufferUint64) ForEach

func (b *BufferUint64) ForEach(fn func(v uint64) error) (e error)

func (*BufferUint64) Get

func (b *BufferUint64) Get(index int) (out *uint64)

Get returns the value at the given index or nil if nothing

type Entry

type Entry struct {
	Sem     semaphore.Semaphore
	Buf     []*logg.Entry
	Cursor  int
	Full    bool
	Clicked int
}

func NewEntry

func NewEntry(size int) *Entry

NewEntry creates a new entry ring buffer

func (*Entry) Add

func (b *Entry) Add(value *logg.Entry)

func (*Entry) Clear

func (b *Entry) Clear()

Clear sets the buffer back to initial state

func (*Entry) ForEach

func (b *Entry) ForEach(fn func(v *logg.Entry) error) (e error)

func (*Entry) Get

func (b *Entry) Get(i int) (out *logg.Entry)

Get returns the value at the given index or nil if nothing

func (*Entry) Len

func (b *Entry) Len() (out int)

Len returns the length of the buffer

Jump to

Keyboard shortcuts

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