timewheel

package
v0.0.0-...-c3f54fb Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delay

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

func NewDelay

func NewDelay() *Delay

func (*Delay) Add

func (d *Delay) Add(interval time.Duration, key string, callback func())

添加延迟任务 相对时间

func (*Delay) AddAt

func (d *Delay) AddAt(expire time.Time, key string, callback func())

添加延迟任务 绝对时间

func (*Delay) Cancel

func (d *Delay) Cancel(key string)

取消延迟任务

type TimeWheel

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

循环队列 + 链表

func New

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

func (*TimeWheel) Add

func (tw *TimeWheel) Add(delay time.Duration, key string, callback func())

func (*TimeWheel) Cancel

func (tw *TimeWheel) Cancel(key string)

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Jump to

Keyboard shortcuts

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