xtask

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stop

func Stop(tasks ...ITask)

func Wait

func Wait(tasks ...ITask)

func WaitAndStop

func WaitAndStop(tasks ...ITask)

Types

type Group

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

func NewGroupTask

func NewGroupTask() *Group

func WithContext

func WithContext(ctx context.Context) (*Group, context.Context)

func (*Group) Go

func (g *Group) Go(fn func())

func (*Group) Wait

func (g *Group) Wait() error

type ITask

type ITask interface {
	// all tasks
	Size() int32
	// task that running
	CurSize() int32
	// task average execution time
	CurDur() time.Duration
	// wait for task to finish
	Wait()
	Do(args ...interface{})
	Stop()
	IsClosed() bool
}

ITask interface

func NewAsyncTask

func NewAsyncTask(max int32, maxDur time.Duration, fn interface{}) ITask

NewAsyncTask max: 最大并发数 maxDur: 任务最大执行时间

Jump to

Keyboard shortcuts

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