Documentation
¶
Overview ¶
多任务
Index ¶
- Constants
- Variables
- func RunTasks(tasks []TaskHandler, timeout ...time.Duration) error
- type Task
- type TaskHandler
- type Work
- func (w *Work) Data() []interface{}
- func (w *Work) Do(work ...WorkHandler)
- func (w *Work) Errors() []error
- func (w *Work) Result() []*WorkResult
- func (w *Work) Run(timeout ...time.Duration) error
- func (w *Work) RunAndData(timeout ...time.Duration) ([]interface{}, error)
- func (w *Work) RunAndResult(timeout ...time.Duration) ([]*WorkResult, error)
- type WorkHandler
- type WorkResult
Constants ¶
View Source
const ( DefaultTimeout = 5 * time.Second DefaultLongTime = 200 * time.Millisecond )
Variables ¶
View Source
var ( ErrTimeout = errors.New("run timeout") ErrNotFound = errors.New("not found") )
Functions ¶
Types ¶
type TaskHandler ¶
type TaskHandler func() error
type Work ¶
func (*Work) Do ¶
func (w *Work) Do(work ...WorkHandler)
func (*Work) RunAndData ¶
执行并获取数据
func (*Work) RunAndResult ¶
func (w *Work) RunAndResult(timeout ...time.Duration) ([]*WorkResult, error)
执行并获取结果
type WorkHandler ¶
type WorkHandler func() (interface{}, error)
type WorkResult ¶
type WorkResult struct {
Data interface{}
Error error
}
func RunWorks ¶
func RunWorks(works []WorkHandler, timeout ...time.Duration) ([]*WorkResult, error)
执行并发任务
Click to show internal directories.
Click to hide internal directories.