queue

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue 封装了 UMPSCQueue 和计数器

func New

func New[T any]() *Queue[T]

New 创建一个新的 Queue 实例

func (*Queue[T]) Dequeue

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

Dequeue 从队列中获取数据并更新计数器 (仅单消费者!!!)

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(value T)

Enqueue 向队列中添加数据并更新计数器 (多生产者: 安全)

func (*Queue[T]) Len

func (q *Queue[T]) Len() uint64

Len 返回当前队列长度

func (*Queue[T]) RateState

func (q *Queue[T]) RateState() (rate float64, enqueueCount, lastEnqueueCount uint64)

RateState 返回入队速率, 当前计数, 上一次计数

Jump to

Keyboard shortcuts

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