Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SingleTimeWheel ¶
type SingleTimeWheel struct {
// contains filtered or unexported fields
}
SingleTimeWheel 定义单级时间轮的数据结构
func NewSingleTimeWheel ¶
func NewSingleTimeWheel(tickDuration time.Duration, slotNumber int) *SingleTimeWheel
NewSingleTimeWheel 新建一个单级时间轮
func (*SingleTimeWheel) AddTask ¶
func (own *SingleTimeWheel) AddTask(delay time.Time, job func(), period time.Duration, repeats ...int) int64
AddTask 添加定时性任务
- delay:执行首轮任务的延迟时间
- job:任务函数
- period:任务重复执行的时间间隔
- repeats:重复执行任务的次数(repeats=-1 表示一直循环执行定时任务)
- 注意:重复执行任务的间隔时间 period 需要大于时间轮的最小嘀嗒时间;
func (*SingleTimeWheel) CancelTask ¶
func (own *SingleTimeWheel) CancelTask(tid int64, done func()) bool
CancelTask 取消任务
- tid:任务ID
- done:任何取消时的回调函数
Click to show internal directories.
Click to hide internal directories.