multi

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTasks

func RunTasks(tasks []TaskHandler, timeout ...int64) error

执行并发任务

func RunWorks

func RunWorks(works []WorkHandler, timeout ...int64) ([]interface{}, error)

执行并发任务

Types

type Task

type Task struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTasks

func NewTasks(task ...TaskHandler) *Task

实例化并发任务

func (*Task) Do

func (t *Task) Do(work ...TaskHandler)

func (*Task) Errors

func (t *Task) Errors() map[int]error

获取全部任务错误

func (*Task) GetError added in v1.3.0

func (t *Task) GetError(i int) error

获取任务错误

func (*Task) Run

func (t *Task) Run(second ...int64) error

执行并发任务

type TaskHandler

type TaskHandler func() error

type Work

type Work struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWorks

func NewWorks(work ...WorkHandler) *Work

实例化并发任务

func (*Work) Do

func (w *Work) Do(work ...WorkHandler)

func (*Work) Errors

func (w *Work) Errors() map[int]error

获取全部任务错误

func (*Work) GetError added in v1.3.0

func (w *Work) GetError(i int) error

获取任务错误

func (*Work) GetResult added in v1.3.0

func (w *Work) GetResult(i int) interface{}

获取任务错误

func (*Work) Result

func (w *Work) Result() []interface{}

获取任务执行结果

func (*Work) Run

func (w *Work) Run(second ...int64) error

执行并发任务

type WorkHandler

type WorkHandler func() (interface{}, error)

Jump to

Keyboard shortcuts

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