task

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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() 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