timewheel

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

时间轮, 定时器

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultCron

func GetDefaultCron() *cron.Cron

func NewCron

func NewCron() *cron.Cron

func NewDefaultCron

func NewDefaultCron()

Types

type Job

type Job func(TaskData)

type TaskData

type TaskData map[interface{}]interface{}

type TimeWheel

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

func NewTimeWheel

func NewTimeWheel(interval time.Duration, slotNam int) *TimeWheel

NewTimeWheel 时间间隔 轮盘大小

func (*TimeWheel) AddTask

func (tw *TimeWheel) AddTask(interval time.Duration, times int, key interface{}, data TaskData, job Job) error

AddTask 添加任务 到时间轮 interval 时间间隔 次数 索引 参数 任务

func (*TimeWheel) RemoveTask

func (tw *TimeWheel) RemoveTask(key interface{}) error

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

func (*TimeWheel) UpdateTask

func (tw *TimeWheel) UpdateTask(key interface{}, interval time.Duration, data TaskData) error

Jump to

Keyboard shortcuts

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