queue

package
v0.0.0-...-6c767d1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultQueueSize = 256

Variables

This section is empty.

Functions

This section is empty.

Types

type FixedQueue

type FixedQueue[T any] struct {
	// contains filtered or unexported fields
}

func NewFixedQueue

func NewFixedQueue[T any](n int) *FixedQueue[T]

NewFixedQueue returns a pointer to a queue whose capacity is the next power of two equal to or greater than n (minimum 2).

func (*FixedQueue[T]) Cap

func (q *FixedQueue[T]) Cap() int64

func (*FixedQueue[T]) Len

func (q *FixedQueue[T]) Len() int64

func (*FixedQueue[T]) Pop

func (q *FixedQueue[T]) Pop() (T, bool)

func (*FixedQueue[T]) PopAtomic

func (q *FixedQueue[T]) PopAtomic() (T, PopResult)

func (*FixedQueue[T]) Push

func (q *FixedQueue[T]) Push(v T) bool

Push attempts to push v into the queue. Returns false if the queue is full.

func (*FixedQueue[T]) PushAtomic

func (q *FixedQueue[T]) PushAtomic(v T) PushResult

type MemorySize

type MemorySize interface {
	MemoryUsage() uint64
}

type PopResult

type PopResult int
const (
	PopFailed PopResult = iota - 1
	PopSuccess
	PopEmpty
)

func (PopResult) IsSuccess

func (r PopResult) IsSuccess() bool

func (PopResult) String

func (r PopResult) String() string

type PushResult

type PushResult int
const (
	PushFailed PushResult = iota - 1
	PushSuccess
	PushFull
)

func (PushResult) IsSuccess

func (r PushResult) IsSuccess() bool

func (PushResult) String

func (r PushResult) String() string

type Queue

type Queue[T any] interface {
	Len() uint64
	Cap() uint64
	PushAtomic(T) PushResult
	Push(v T) bool
	PopAtomic() (T, PopResult)
	Pop() (T, bool)
}

Jump to

Keyboard shortcuts

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