scheduler

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsElastic added in v0.3.1

func IsElastic(sc Scheduler) bool

func IsParallel added in v0.3.1

func IsParallel(sc Scheduler) bool

func IsSingle added in v0.3.1

func IsSingle(sc Scheduler) bool

Types

type Scheduler

type Scheduler interface {
	io.Closer
	// Name return the name of scheduler.
	Name() string
	// Worker returns next worker.
	Worker() Worker
}

Scheduler schedule tasks.

func Elastic

func Elastic() Scheduler

Elastic is a dynamic alloc scheduler. It's based on ants goroutine pool.

func ElasticBounded added in v0.3.4

func ElasticBounded() Scheduler

ElasticBounded is a dynamic scheduler with bounded size. It's based on ants goroutine pool.

func Immediate

func Immediate() Scheduler

Immediate returns a scheduler which schedule tasks _immediate.

func NewAnts added in v0.4.7

func NewAnts(pool *ants.Pool) Scheduler

NewAnts creates a new scheduler over ants pool.

func NewElastic added in v0.0.9

func NewElastic(size int) Scheduler

NewElastic creates a new elastic scheduler.

func NewSingle added in v0.0.10

func NewSingle() Scheduler

NewSingle creates a new single scheduler with customized cap.

func Parallel added in v0.0.11

func Parallel() Scheduler

Parallel returns scheduler which schedule tasks in _parallel using native goroutines.

func Single added in v0.0.10

func Single() Scheduler

Single returns a scheduler which schedule tasks on a single goroutine. It will execute tasks one by one.

type Task added in v0.1.4

type Task func()

Task defines task function.

type Worker

type Worker interface {
	// Do executes a task.
	Do(Task) error
}

Worker is used to execute a task.

Jump to

Keyboard shortcuts

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