Help us shape the future of Go! Take the 2026 Go Developer Survey

queue

package
v1.12.11 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STOPPED  = 0 // 已停止
	STARTING = 1 // 启动中
	RUNNING  = 2 // 运行中
	WAITING  = 3 // 等待关闭中
)

Variables

This section is empty.

Functions

func GenId

func GenId() uint64

Types

type Attribute

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

func (*Attribute) Closed

func (d *Attribute) Closed()

func (*Attribute) GetId

func (d *Attribute) GetId() uint64

func (*Attribute) GetIdPointer

func (d *Attribute) GetIdPointer() *uint64

func (*Attribute) GetName

func (d *Attribute) GetName() string

func (*Attribute) GetSize

func (d *Attribute) GetSize() int

func (*Attribute) GetStatus

func (d *Attribute) GetStatus() int32

func (*Attribute) IsClosed

func (d *Attribute) IsClosed() bool

func (*Attribute) IsRunning

func (d *Attribute) IsRunning() bool

func (*Attribute) IsStarting

func (d *Attribute) IsStarting() bool

func (*Attribute) IsWaiting

func (d *Attribute) IsWaiting() bool

func (*Attribute) OnDelete

func (d *Attribute) OnDelete()

func (*Attribute) OnLock

func (d *Attribute) OnLock() error

func (*Attribute) OnUnlock

func (d *Attribute) OnUnlock() error

func (*Attribute) Running

func (d *Attribute) Running()

func (*Attribute) SetId

func (d *Attribute) SetId(val uint64)

func (*Attribute) SetStatus

func (d *Attribute) SetStatus(val int32)

func (*Attribute) Starting

func (d *Attribute) Starting()

func (*Attribute) Waiting

func (d *Attribute) Waiting()

type ITask

type ITask interface {
	Do() bool
}

type MsgQueue

type MsgQueue[T ITask] struct {
	*Attribute // 基础
	// contains filtered or unexported fields
}

func NewMsgQueue

func NewMsgQueue[T ITask](opts ...Option) *MsgQueue[T]

func (*MsgQueue[T]) Push

func (d *MsgQueue[T]) Push(t T) (flag bool)

func (*MsgQueue[T]) Start

func (d *MsgQueue[T]) Start(except func(string, ...any)) error

func (*MsgQueue[T]) Stop

func (d *MsgQueue[T]) Stop()

func (*MsgQueue[T]) Wait

func (d *MsgQueue[T]) Wait()

type MsgQueuePool

type MsgQueuePool[T ITask] struct {
	*Attribute // 基础
	// contains filtered or unexported fields
}

func NewMsgQueuePool

func NewMsgQueuePool[T ITask](opts ...Option) *MsgQueuePool[T]

func (*MsgQueuePool[T]) Push

func (d *MsgQueuePool[T]) Push(t T) (flag bool)

func (*MsgQueuePool[T]) Start

func (d *MsgQueuePool[T]) Start(except func(string, ...any)) error

func (*MsgQueuePool[T]) Stop

func (d *MsgQueuePool[T]) Stop()

func (*MsgQueuePool[T]) Wait

func (d *MsgQueuePool[T]) Wait()

type Option

type Option func(*Attribute)

func WithDeleter

func WithDeleter(f func(uint64)) Option

func WithId

func WithId(id uint64) Option

WithId 设置唯一id(不修改 name)

func WithIdleTime

func WithIdleTime(idle int64) Option

func WithLocker

func WithLocker(expire int64, lock func(uint64, time.Duration) error, unlock func(uint64) error) Option

func WithName

func WithName(name string) Option

func WithSize

func WithSize(size int) Option

WithSize 设置分片大小

type Queue

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

func NewQueue

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

func (*Queue[T]) GetCount

func (d *Queue[T]) GetCount() int32

func (*Queue[T]) Pop

func (d *Queue[T]) Pop() (ret T, ok bool)

Pop 尝试从队列弹出元素,如果队列为空或 CAS 失败则返回零值和 false

func (*Queue[T]) Push

func (d *Queue[T]) Push(val T, cb func()) int32

Jump to

Keyboard shortcuts

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