task

package
v0.1.15 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLog added in v0.1.8

func InitLog()

func Stop added in v0.1.2

func Stop(tasks ...ITask)

func Wait added in v0.1.2

func Wait(tasks ...ITask)

func WaitAndStop added in v0.1.2

func WaitAndStop(tasks ...ITask)

Types

type Group added in v0.1.8

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

func NewGroupTask added in v0.1.10

func NewGroupTask() *Group

func WithContext added in v0.1.8

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

func (*Group) Go added in v0.1.8

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

func (*Group) Wait added in v0.1.8

func (g *Group) Wait() error

type ITask added in v0.1.0

type ITask interface {
	Size() int
	CurSize() int
	Wait()
	Stat() Stat
	Do(args ...interface{})
	Stop()
	OnError(err error)
}

ITask interface

func NewAsyncTask

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

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

type Stat

type Stat struct {
	// QL queue length
	QL int `json:"q_l,omitempty"`

	// CurDur current duration
	CurDur float64 `json:"cur_dur,omitempty"`

	// MaxQ max queue
	MaxQ int `json:"max_q,omitempty"`

	// MaxDur max duration
	MaxDur float64 `json:"max_dur,omitempty"`
}

Stat stat struct

Jump to

Keyboard shortcuts

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