concurrent

package
v1.0.0-pre3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FanOut

func FanOut[T any](data types.IFanOut[T], number int) []T

func RunSafe

func RunSafe(handler func(), errHandler ...types.ErrHandler)

RunSafe 捕获panic的协程

func WaitGroup

func WaitGroup(number int, handler types.WaitGroupHandler, closeHandler ...func()) error

WaitGroup wait group封装

Types

type Limit

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

Limit 限制并发器,限制最大同时运行的数量

func NewLimit

func NewLimit(max int) *Limit

func (*Limit) Get

func (r *Limit) Get()

func (*Limit) Put

func (r *Limit) Put()

type PriorityChan

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

func NewPriorityChan

func NewPriorityChan[T any](size int) *PriorityChan[T]

func (*PriorityChan[T]) Get

func (p *PriorityChan[T]) Get() T

Get 获取数据,阻塞等待

func (*PriorityChan[T]) GetWithTimeout

func (p *PriorityChan[T]) GetWithTimeout(timeout time.Duration) (T, error)

GetWithTimeout 获取数据,支持超时返回

func (*PriorityChan[T]) HandleSignal

func (p *PriorityChan[T]) HandleSignal(highHandler types.PriorityHandler, lowHandler types.PriorityHandler) error

HandleSignal 通过传入处理函数,处理队列信号

func (*PriorityChan[T]) TryGet

func (p *PriorityChan[T]) TryGet() T

TryGet 尝试获取数据,如果没准备好直接返回

Jump to

Keyboard shortcuts

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