修复时间轮代码

This commit is contained in:
liwei 2023-07-13 11:36:06 +08:00
parent 0a17fb1517
commit 1c070e2646

View File

@ -185,8 +185,9 @@ func (this *TimeWheel) handleTick() {
} }
if task.async { if task.async {
go func(task *Task) { go func(_task *Task) {
go this.calltask(task, task.args...) this.calltask(_task, _task.args...)
this.collectTask(task)
}(task) }(task)
} else { } else {
@ -202,8 +203,10 @@ func (this *TimeWheel) handleTick() {
} }
// gc // gc
if !task.async {
this.collectTask(task) this.collectTask(task)
} }
}
if this.currentIndex == this.bucketsNum-1 { if this.currentIndex == this.bucketsNum-1 {
this.currentIndex = 0 this.currentIndex = 0