timewheel

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetTimeWheel

func SetTimeWheel(t *TimeWheel)

Types

type Job

type Job func(arge interface{})

Job 延时任务回调函数

type Task

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

Task 延时任务

type TaskData

type TaskData interface{}

TaskData 回调函数参数类型

type TimeWheel

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

TimeWheel 时间轮

func GetTimeWheel

func GetTimeWheel() *TimeWheel

func New

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

New 创建时间轮

func (*TimeWheel) AddTimer

func (tw *TimeWheel) AddTimer(delay time.Duration, data TaskData, job Job)

AddTimer 添加定时器 不可撤销

func (*TimeWheel) AddTimerCustom

func (tw *TimeWheel) AddTimerCustom(delay time.Duration, key interface{}, data TaskData, job Job)

可以通过key来撤销一个未执行的定时器

func (*TimeWheel) RemoveTimer

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

RemoveTimer 删除定时器 key为添加定时器时传递的定时器唯一标识

func (*TimeWheel) Start

func (tw *TimeWheel) Start(closeSig chan bool)

Start 启动时间轮

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop 停止时间轮

Jump to

Keyboard shortcuts

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