timingwheel

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Execute

type Execute func(key, value interface{})

Execute defines the method to execute the task.

type TimingWheel

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

A TimingWheel is a timing wheel object to schedule tasks.

func NewTimingWheel

func NewTimingWheel(interval time.Duration, numSlots int, execute Execute) (*TimingWheel, error)

NewTimingWheel returns a TimingWheel.

func (*TimingWheel) Drain

func (tw *TimingWheel) Drain(fn func(key, value interface{}))

Drain drains all items and executes them.

func (*TimingWheel) GetValue

func (tw *TimingWheel) GetValue(key string) (interface{}, bool)

func (*TimingWheel) Len

func (tw *TimingWheel) Len() int

func (*TimingWheel) MoveTimer

func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration)

MoveTimer moves the task with the given key to the given delay.

func (*TimingWheel) RemoveTimer

func (tw *TimingWheel) RemoveTimer(key interface{})

RemoveTimer removes the task with the given key.

func (*TimingWheel) SetTimer

func (tw *TimingWheel) SetTimer(key, value interface{}, delay time.Duration)

SetTimer sets the task value with the given key to the delay.

func (*TimingWheel) Stop

func (tw *TimingWheel) Stop()

Stop stops tw.

Jump to

Keyboard shortcuts

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