timewheel

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetTimeWheel added in v1.8.0

func SetTimeWheel(t *TimeWheel)

Types

type Job added in v1.8.0

type Job func(arge interface{})

Job 延时任务回调函数

type Task added in v1.8.0

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

Task 延时任务

type TaskData added in v1.8.0

type TaskData interface{}

TaskData 回调函数参数类型

type TimeWheel added in v1.8.0

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

TimeWheel 时间轮

func GetTimeWheel added in v1.8.0

func GetTimeWheel() *TimeWheel

func New added in v1.8.0

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

New 创建时间轮

func (*TimeWheel) AddTimer added in v1.8.0

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

AddTimer 添加定时器 不可撤销

func (*TimeWheel) AddTimerCustom added in v1.8.0

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

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

func (*TimeWheel) RemoveTimer added in v1.8.0

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

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

func (*TimeWheel) Start added in v1.8.0

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

Start 启动时间轮

func (*TimeWheel) Stop added in v1.8.0

func (tw *TimeWheel) Stop()

Stop 停止时间轮

Jump to

Keyboard shortcuts

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