pool

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Goroutine

type Goroutine interface {
	Run(ctx context.Context)
}

Goroutine 协程任务接口

type Pool

type Pool[T Goroutine] struct {
	// contains filtered or unexported fields
}

Pool 协程池

func NewPool

func NewPool[T Goroutine](number, size int, ctx context.Context) *Pool[T]

NewPool 初始化线程池 number 协程数 size 单协程任务数量 ctx 上下文变量

func (*Pool[T]) Add

func (pool *Pool[T]) Add(task T)

Add 添加任务

func (*Pool[T]) Recover

func (pool *Pool[T]) Recover(rec RunTimeErr)

Recover 自定义错误处理器

func (*Pool[T]) Start

func (pool *Pool[T]) Start()

Start 启动协程池

func (*Pool[T]) Stop

func (pool *Pool[T]) Stop()

Stop 关闭协程池

type RunTimeErr

type RunTimeErr interface {
	Catch()
}

RunTimeErr 协程池运行错误捕捉接口

Jump to

Keyboard shortcuts

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