queue

package
v0.0.0-...-1a2806f Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanQueue

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

ChanQueue use chan queue

func (*ChanQueue) AsyncPop

func (q *ChanQueue) AsyncPop() (val interface{}, err error)

AsyncPop async pop

func (*ChanQueue) AsyncPush

func (q *ChanQueue) AsyncPush(x interface{}) (err error)

AsyncPush async push data

func (*ChanQueue) AutoPop

func (q *ChanQueue) AutoPop() ([]interface{}, error)

func (*ChanQueue) Capacity

func (q *ChanQueue) Capacity() int32

Capacity get queue capacity

func (*ChanQueue) Close

func (q *ChanQueue) Close() error

Close 不需要关闭innerChan,交给GC回收,多写的时候直接关闭innerChan会出问题

func (*ChanQueue) ForceClose

func (q *ChanQueue) ForceClose() error

func (*ChanQueue) IsClosed

func (q *ChanQueue) IsClosed() bool

IsClosed if chan is close,return true

func (*ChanQueue) IsFull

func (q *ChanQueue) IsFull() bool

IsFull queue is full return true

func (*ChanQueue) Length

func (q *ChanQueue) Length() int32

Length get chan queue length

func (*ChanQueue) Pop

func (q *ChanQueue) Pop() (val interface{}, err error)

Pop sync block pop

func (*ChanQueue) Push

func (q *ChanQueue) Push(x interface{}) error

Push sync push data

type Queue

type Queue interface {

	// Push 阻塞写队列
	Push(data interface{}) error
	// AsyncPush 异步非阻塞写队列
	AsyncPush(data interface{}) error
	// Pop 阻塞读队列
	Pop() (interface{}, error)
	//AutoPop 批量获取阻塞读队列
	AutoPop() ([]interface{}, error)
	// AsyncPop 异步读队列
	AsyncPop() (interface{}, error)
	// Capacity 队列大小
	Capacity() int32
	// Length 队列占用数量
	Length() int32
	// Close 关闭队列
	Close() error
	// 强制关闭
	ForceClose() error
	// IsClosed 队列是否已经关闭 关闭返回true,否则返回false
	IsClosed() bool
}

Queue interface define

func NewChanQueue

func NewChanQueue(capacity int32) Queue

NewChanQueue create chan queue

Jump to

Keyboard shortcuts

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