threadPool

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MulanPSL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultTheadEvent

type DefaultTheadEvent struct {
	PoolEvent PoolEvent
}

默认事件推荐器

func (*DefaultTheadEvent) SetPoolEvent

func (this *DefaultTheadEvent) SetPoolEvent(poolEvent PoolEvent)

设置事件器 @param PoolEvent 事件器

type PoolEvent

type PoolEvent interface {
	IsCancel() bool                           // 是否取消
	Ctx() context.Context                     // 获取上下文
	AddErr(message string, threadName string) // 设置错误
	Cancel(message string)                    // 执行取消
}

线程事件

type PoolManager

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

线程池管理 @author fuzeyu

func (*PoolManager) AddErr

func (this *PoolManager) AddErr(message string, threadName string)

添加一个错误 @param message 错误消息 @param threadName 线程名称

func (*PoolManager) Cancel

func (this *PoolManager) Cancel(message string)

执行取消

func (*PoolManager) Ctx

func (this *PoolManager) Ctx() context.Context

获取上下文参数

func (*PoolManager) ExecuteEvent

func (this *PoolManager) ExecuteEvent(callback ThreadEvent)

执行一个事件 @param callback 事件回调方法

func (*PoolManager) Init

func (this *PoolManager) Init(durations ...time.Duration) *PoolManager

初始化 @param seconds 工作时长

func (*PoolManager) IsCancel

func (this *PoolManager) IsCancel() bool

是否取消

func (*PoolManager) Wait

func (this *PoolManager) Wait() error

等待全部事件执行完成

type ThreadEvent

type ThreadEvent interface {
	SetPoolEvent(poolEvent PoolEvent)
	Execute()
}

执行一个事件的方法

Jump to

Keyboard shortcuts

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