taskexcutor

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PoolStopedError = errors.New("task pool stoped")
	PoolFullError   = errors.New("task pool full")
)

Functions

func SetGExcutor

func SetGExcutor(excutor Excutor)

Types

type CallBack

type CallBack func(...interface{})

事件回调

type Excutor

type Excutor interface {
	//执行方法
	Excute(task *TaskService) error
	//执行器关闭方法
	Close()
}

任务执行器

func GExcutor

func GExcutor() Excutor

func NewTaskPoolExcutor

func NewTaskPoolExcutor(poolSize, chanSize uint, shutdownNow bool, shutdownWait time.Duration) Excutor

type MultiplePoolExcutor

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

并发执行器

func (*MultiplePoolExcutor) Close

func (p *MultiplePoolExcutor) Close()

Excutor.Close()

func (*MultiplePoolExcutor) Excute

func (p *MultiplePoolExcutor) Excute(task *TaskService) error

Excutor.Excute()

type TaskExcutor

type TaskExcutor chan *TaskService

func NewTaskExcutor

func NewTaskExcutor(chanSize int) TaskExcutor

func (TaskExcutor) Close

func (c TaskExcutor) Close()

func (TaskExcutor) Excute

func (c TaskExcutor) Excute(task *TaskService) (err error)

type TaskService

type TaskService struct {
	Cancel bool //是否取消回调
	ID     interface{}
	// contains filtered or unexported fields
}

func NewTaskService

func NewTaskService(callback CallBack, params ...interface{}) *TaskService

func (*TaskService) AddArgs

func (t *TaskService) AddArgs(startIndex int, args ...interface{}) *TaskService

添加回调函数参数,startIndex<0表示顺序添加,startIndex>=0表示将参数从指定位置开始添加,原来位置的参数依次后移

func (*TaskService) Call

func (t *TaskService) Call()

代理执行

func (*TaskService) GetArg

func (t *TaskService) GetArg(index int) interface{}

获取指定下标的参数

func (*TaskService) SetArg

func (t *TaskService) SetArg(index int, arg interface{})

重置指定下标的参数

func (*TaskService) SetArgs

func (t *TaskService) SetArgs(args ...interface{}) *TaskService

重置参数

Jump to

Keyboard shortcuts

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