scheduler

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close stops the scheduler

func Repeat

func Repeat(task Task, interval time.Duration)

Repeat runs the task repeatly at every interval

func Run

func Run(task Task)

Run add task to scheduler for immediate execution

Types

type LocalScheduler

type LocalScheduler interface {
	Schedule(Task)
}

LocalScheduler schedules task to a customized goroutine

type Task

type Task func()

Task is a function

type TimedSched

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

TimedSched represents the control struct for timed parallel scheduler. This scheduler also executes runnable tasks at the same go routine. It is inefficient for programs create and delete timers frequently, because leaving a lot of timers in the heap slows down addtimer. If your program create and delete a lot of short period timers, use a time-wheel mechanism such as https://github.com/andy2046/tik

func NewTimedSched

func NewTimedSched(parallel int) *TimedSched

NewTimedSched creates a parallel-scheduler with given parallelization

func (*TimedSched) Close

func (ts *TimedSched) Close()

Close terminates this scheduler

func (*TimedSched) Put

func (ts *TimedSched) Put(f func(), deadline time.Time)

Put a function 'f' awaiting to be executed at 'deadline'

func (*TimedSched) Run

func (ts *TimedSched) Run(f func())

Run a function 'f' immediately

Jump to

Keyboard shortcuts

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