bufferfifo

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FIFO

type FIFO struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FIFO is a simple queue designed to queue packets. It can also be used as a freelist using the PopOrCreate function

func New

func New(allocSize int) *FIFO

New creates the FIFO. All allocations will be a multiple of allocSize to reduce the need to reallocate

func (*FIFO) Clear

func (b *FIFO) Clear() int

Clear removes all elements form the FIFO and returns how many there were

func (*FIFO) Len

func (b *FIFO) Len() int

Len returns the number of elements in the FIFO

func (*FIFO) Pop

func (b *FIFO) Pop() *pdu.PDU

Pop removes and returns the first element of the FIFO. It there is no element nil is returned

func (*FIFO) Push

func (b *FIFO) Push(buf *pdu.PDU) int

Push inserts buf at the end of the FIFO. Returns number of elements in FIFO.

func (*FIFO) Reallocate

func (b *FIFO) Reallocate()

Reallocate reallocates the internal ring buffer. This can be used to free some memory after an episode of heavy load.

Jump to

Keyboard shortcuts

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