Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type TimeWheel ¶
type TimeWheel struct {
// contains filtered or unexported fields
}
TimeWheel 时间轮
func NewTimeWheel ¶
NewTimeWheel New 创建时间轮 初始化时间轮 interval 第一个参数为tick刻度, 即时间轮多久转动一次 slotNum 第二个参数为时间轮槽slot数量 interval 精确到秒 , 精度越高越耗性能 ,建议到秒级别 使用步骤 1、newtimewheel 2、start 3、addtimer 4 stop
func (*TimeWheel) AddTimer ¶
func (tw *TimeWheel) AddTimer(delay time.Duration, key interface{}, callBack JobFunc, args ...interface{})
AddTimer 添加定时器 key为定时器唯一标识
func (*TimeWheel) RemoveTimer ¶
func (tw *TimeWheel) RemoveTimer(key interface{})
RemoveTimer 删除定时器 key为添加定时器时传递的定时器唯一标识
Click to show internal directories.
Click to hide internal directories.