queue

package
v0.0.0-...-5989d0e Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundedQ

type BoundedQ struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BoundedQ is a struct that acts as a queue (FIFO), with a limit imposed on the number of elements that it could hold. It can safely be used across goroutines.

func (*BoundedQ) Len

func (q *BoundedQ) Len() int

Len returns the number of elements in the queue

func (*BoundedQ) Pop

func (q *BoundedQ) Pop() interface{}

Pop removes and returns the first element from the queue

func (*BoundedQ) Push

func (q *BoundedQ) Push(element interface{})

Push adds an element to the queue

func (*BoundedQ) SetMaxLength

func (q *BoundedQ) SetMaxLength(length int) error

SetMaxLength would set the maximum size of the queue >=0. If 0, it would behave as a normal queue. If < 0, it would throw an error.

Jump to

Keyboard shortcuts

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