Browse Source

修正issues/85 ids越界问题

master
aceld 4 years ago
parent
commit
84d9236944
  1. 5
      ztimer/timerscheduler.go

5
ztimer/timerscheduler.go

@ -91,14 +91,17 @@ func (this *TimerScheduler) CancelTimer(tid uint32) {
this.Unlock() this.Unlock()
//this.tw.RemoveTimer(tid) 这个方法无效 //this.tw.RemoveTimer(tid) 这个方法无效
//删除timerId //删除timerId
var index = 0
var index = -1
for i := 0; i < len(this.ids); i++ { for i := 0; i < len(this.ids); i++ {
if this.ids[i] == tid { if this.ids[i] == tid {
index = i index = i
} }
} }
if index > -1 {
this.ids = append(this.ids[:index], this.ids[index+1:]...) this.ids = append(this.ids[:index], this.ids[index+1:]...)
} }
}
//获取计时结束的延迟执行函数通道 //获取计时结束的延迟执行函数通道
func (this *TimerScheduler) GetTriggerChan() chan *DelayFunc { func (this *TimerScheduler) GetTriggerChan() chan *DelayFunc {

Loading…
Cancel
Save