queues

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LFQueue

type LFQueue struct {
	// contains filtered or unexported fields
}

LFQueue 无锁(Lock-free)队列实现

func NewLFQueue

func NewLFQueue() *LFQueue

func (*LFQueue) Pop

func (q *LFQueue) Pop() unsafe.Pointer

func (*LFQueue) Push

func (q *LFQueue) Push(value unsafe.Pointer)

type MPSC

type MPSC struct {
	// contains filtered or unexported fields
}

func NewMPSC

func NewMPSC() *MPSC

func (*MPSC) Empty

func (q *MPSC) Empty() bool

Empty 如果队列为空将返回 true

  • 必须从单个消费者 goroutine 调用

func (*MPSC) Pop

func (q *MPSC) Pop() any

Pop 从队列前面删除项目,如果队列为空则为 nil

  • 必须从单个消费者 goroutine 调用

func (*MPSC) Push

func (q *MPSC) Push(m any)

Push 将 m 添加到队列末尾。

  • 可以从多个 goroutine 安全地调用 Push

Jump to

Keyboard shortcuts

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