workerpools

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStop

func IsStop() bool

func OnInit

func OnInit(config map[string]interface{}, option ...Option) (err error)

func Stop

func Stop()

func StopWait

func StopWait()

func Submit

func Submit(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})

func SubmitWait

func SubmitWait(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})

func WaitingQueueSize

func WaitingQueueSize() int

Types

type IWorkerPool

type IWorkerPool interface {
	Stop()
	StopWait()
	IsStop() bool
	Submit(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})
	SubmitWait(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})
	WaitingQueueSize() int
}

func NewSys

func NewSys(option ...Option) (sys IWorkerPool, err error)

type Option

type Option func(*Options)

func SetDefWorkers

func SetDefWorkers(v int) Option

func SetMaxWorkers

func SetMaxWorkers(v int) Option

func SetTaskTimeOut

func SetTaskTimeOut(v time.Duration) Option

type Options

type Options struct {
	DefWrokers     int
	MaxWorkers     int
	Tasktimeout    time.Duration //任务执行操超时间
	IdleTimeoutSec time.Duration //超时释放空闲工作人员
}

type Task

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

type WorkerPool

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

func (*WorkerPool) IsStop

func (p *WorkerPool) IsStop() bool

func (*WorkerPool) Stop

func (p *WorkerPool) Stop()

func (*WorkerPool) StopWait

func (p *WorkerPool) StopWait()

func (*WorkerPool) Submit

func (p *WorkerPool) Submit(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})

func (*WorkerPool) SubmitWait

func (p *WorkerPool) SubmitWait(task func(ctx context.Context, cancel context.CancelFunc, agrs ...interface{}), agrs ...interface{})

func (*WorkerPool) WaitingQueueSize

func (p *WorkerPool) WaitingQueueSize() int

Jump to

Keyboard shortcuts

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