timewheel

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func At

func At(at time.Time, key string, job func())

At executes job at given time

func Cancel

func Cancel(key string)

Cancel stops a pending job

func Delay

func Delay(duration time.Duration, key string, job func())

Delay executes job after waiting the given duration

Types

type TimeWheel

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

TimeWheel can execute job after waiting given duration

func New

func New(interval time.Duration, slotNum int) *TimeWheel

New creates a new time wheel

func (*TimeWheel) AddJob added in v1.2.5

func (tw *TimeWheel) AddJob(delay time.Duration, key string, job func())

AddJob add new job into pending queue

func (*TimeWheel) RemoveJob added in v1.2.5

func (tw *TimeWheel) RemoveJob(key string)

RemoveJob add remove job from pending queue if job is done or not found, then nothing happened

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

Start starts ticker for time wheel

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop stops the time wheel

Jump to

Keyboard shortcuts

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