workpool

package
v0.0.0-...-6b4248b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loop

func Loop(max int, wp *WorkPool)

func StartQueue

func StartQueue(wp *WorkPool)

func WaitTask

func WaitTask(wp *WorkPool)

Types

type TaskHandler

type TaskHandler func() error

type WorkPool

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

func New

func New(max int) *WorkPool

注册工作池,并设置最大并发数。

func (*WorkPool) Do

func (wp *WorkPool) Do(th TaskHandler)

添加任务到工作池,并立即返回。

func (*WorkPool) DoWait

func (wp *WorkPool) DoWait(th TaskHandler)

添加任务到工作池,并等待执行完成之后再返回。

func (*WorkPool) IsClosed

func (wp *WorkPool) IsClosed() bool

是否已经关闭

func (*WorkPool) IsDone

func (wp *WorkPool) IsDone() bool

判断是否完成 (非阻塞)

func (*WorkPool) SetTimeOut

func (wp *WorkPool) SetTimeOut(timeout time.Duration)

设置超时时间

func (*WorkPool) Wait

func (wp *WorkPool) Wait() error

等待工作线程执行结束

Jump to

Keyboard shortcuts

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