queue

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueIsEmpty = errors.New("queue is empty")
View Source
var ErrQueueIsEmptyTimeout = errors.New("queue is empty timeout")
View Source
var ErrQueueIsFull = errors.New("queue is full")
View Source
var ErrQueueIsFullTimeout = errors.New("queue is full timeout")

Functions

This section is empty.

Types

type Queue

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

func NewPacketQueue

func NewPacketQueue(length int) *Queue[*packet.Packet]

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

func (*Queue[T]) Length

func (q *Queue[T]) Length() int

func (*Queue[T]) Pop

func (q *Queue[T]) Pop(handle func(T))

Pop 获取数据,非阻塞 (handle将阻塞获取)

func (*Queue[T]) PopBlock

func (q *Queue[T]) PopBlock() (pkg T)

PopBlock 获取数据,阻塞

func (*Queue[T]) PopJudge

func (q *Queue[T]) PopJudge() (pkg T, err error)

PopJudge 获取数据,非阻塞,如果队列为空则放弃获取

func (*Queue[T]) PopSig

func (q *Queue[T]) PopSig() chan T

func (*Queue[T]) PopTimeout

func (q *Queue[T]) PopTimeout(timeout time.Duration) (pkg T, err error)

PopTimeout 获取数据,阻塞,如果超时则放弃

func (*Queue[T]) Push

func (q *Queue[T]) Push(pkg T)

Push 推送到队列,非阻塞

func (*Queue[T]) PushBlock

func (q *Queue[T]) PushBlock(pkg T)

PushBlock 推送到队列,阻塞

func (*Queue[T]) PushJudge

func (q *Queue[T]) PushJudge(pkg T) error

PushJudge 推送到队列,非阻塞,如果队列已满则放弃推送

func (*Queue[T]) PushTimeout

func (q *Queue[T]) PushTimeout(pkg T, timeout time.Duration) error

PushTimeout 推送到队列,阻塞,如果超时则放弃

Jump to

Keyboard shortcuts

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