xtask

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 11 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 {
	Size() int32
	CurSize() int32
	Wait()
	Stat() Stat
	Do(args ...interface{})
	Stop()
	IsClosed() bool
}

ITask interface

func NewAsyncTask

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

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

type Stat

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

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

	// MaxQ max queue
	MaxQ int32 `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