queue

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICounter

type ICounter interface {
	Counter() uint64
}

type MetricsTracer

type MetricsTracer[T any] interface {
	ItemQueued(name string, item T)
	ItemPop(name string, item T)
}

type PriorityQueue

type PriorityQueue[T ICounter] struct {
	// contains filtered or unexported fields
}

A priorityMessageQueue implements heap.Interface and holds Items.

func NewPriorityQueue

func NewPriorityQueue[T ICounter](name string, tracer MetricsTracer[T]) *PriorityQueue[T]

func (*PriorityQueue[T]) Add

func (pq *PriorityQueue[T]) Add(m T)

func (*PriorityQueue[T]) Len

func (pq *PriorityQueue[T]) Len() (l int)

func (*PriorityQueue[T]) Less

func (pq *PriorityQueue[T]) Less(i, j int) bool

func (*PriorityQueue[T]) Next

func (pq *PriorityQueue[T]) Next() (item T)

func (*PriorityQueue[T]) NextAll

func (pq *PriorityQueue[T]) NextAll(cb func(next T) error) error

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() (item interface{})

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x interface{})

func (*PriorityQueue[T]) Size

func (pq *PriorityQueue[T]) Size() (l int)

func (*PriorityQueue[T]) Swap

func (pq *PriorityQueue[T]) Swap(i, j int)

type SimpleQueue

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

func NewSimpleQueue

func NewSimpleQueue[T any](name string, tracer MetricsTracer[T]) *SimpleQueue[T]

func (*SimpleQueue[T]) Add

func (q *SimpleQueue[T]) Add(m T)

Add pushes an item to the queue

func (*SimpleQueue[T]) Pop

func (q *SimpleQueue[T]) Pop() (m T, ok bool)

Pop removes and returns the first item from the queue. If the queue is empty, the second returned value will be false.

func (*SimpleQueue[T]) WaitForItem

func (q *SimpleQueue[T]) WaitForItem(ctx context.Context) (item T, ok bool)

WaitForItem blocks until a new item is available or the context is canceled. It returns the new item along with a boolean value indicating whether context has expired.

Jump to

Keyboard shortcuts

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