Closed zhangxa closed 1 year ago
感谢提供PR,已经修正。https://github.com/aceld/zinx/blob/master/ztimer/timerscheduler.go
//删除timer
func (this *TimerScheduler) CancelTimer(tid uint32) {
this.Lock()
this.Unlock()
//this.tw.RemoveTimer(tid) 这个方法无效
//删除timerId
var index = -1
for i := 0; i < len(this.ids); i++ {
if this.ids[i] == tid {
index = i
}
}
if index > -1 {
this.ids = append(this.ids[:index], this.ids[index+1:]...)
}
}
this.Unlock() //此处是不是少了 defer ?
//删除timer
func (this *TimerScheduler) CancelTimer(tid uint32) {
this.Lock()
this.Unlock() //此处是不是少了 defer ?
//this.tw.RemoveTimer(tid) 这个方法无效
//删除timerId
var index = -1
for i := 0; i < len(this.ids); i++ {
if this.ids[i] == tid {
index = i
}
}
if index > -1 {
this.ids = append(this.ids[:index], this.ids[index+1:]...)
}
}
@me10001 @aceld 确实是少了defer
已更正。
//删除timer func (this *TimerScheduler) CancelTimer(tid uint32) { this.Lock() this.Unlock() //this.tw.RemoveTimer(tid) 这个方法无效 //删除timerId var index = -1 //此处的0可修改为-1 for i := 0; i < len(this.ids); i++ { if this.ids[i] == tid { index = i } } //此处加个判断 if index > -1 { this.ids = append(this.ids[:index], this.ids[index+1:]...) }
}