task

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	Context  context.Context
	TaskChan chan ITask
	CtrChan  chan struct{}

	IsStopAddTask bool
	StopChan      chan struct{}
	IoWait        time.Duration
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(ctx context.Context, maxTaskNum int) *Dispatcher

func (*Dispatcher) AddTask

func (d *Dispatcher) AddTask(task ITask)

func (*Dispatcher) GetIoWait

func (d *Dispatcher) GetIoWait() time.Duration

func (*Dispatcher) GetStopAddTask

func (d *Dispatcher) GetStopAddTask() bool

func (*Dispatcher) SetIoWait

func (d *Dispatcher) SetIoWait(duration time.Duration)

func (*Dispatcher) StopAddTask

func (d *Dispatcher) StopAddTask()

func (*Dispatcher) Wait

func (d *Dispatcher) Wait()

type ITask

type ITask interface {
	Do()
}

type TaskPool

type TaskPool struct {
	Max int
	// contains filtered or unexported fields
}

func NewTaskPool

func NewTaskPool(max int, handler func(*TaskPool)) *TaskPool

func (*TaskPool) Add

func (t *TaskPool) Add(i int)

func (*TaskPool) Done

func (t *TaskPool) Done()

func (*TaskPool) Run

func (t *TaskPool) Run()

Jump to

Keyboard shortcuts

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