diff --git a/listhead.go b/listhead.go index 04248bd..4252fff 100644 --- a/listhead.go +++ b/listhead.go @@ -48,4 +48,6 @@ func (this *ListHead) Empty() bool { } func (this *ListHead) DelInit() { + this.Del() + this.Init() } diff --git a/timer.go b/timer.go index 4d6cc5d..cc3ac3c 100644 --- a/timer.go +++ b/timer.go @@ -92,10 +92,10 @@ func (this *Timer) Update() { index := uint32(this.timerTick & TVR_MASK) if index != 0 && - this.cascade(&this.tv2, this.getTimerIndex(index)) != 0 && - this.cascade(&this.tv3, this.getTimerIndex(index)) != 0 && - this.cascade(&this.tv4, this.getTimerIndex(index)) != 0 { - this.cascade(&this.tv5, this.getTimerIndex(index)) + this.cascade(&this.tv2, this.getTimerIndex(0)) != 0 && + this.cascade(&this.tv3, this.getTimerIndex(1)) != 0 && + this.cascade(&this.tv4, this.getTimerIndex(2)) != 0 { + this.cascade(&this.tv5, this.getTimerIndex(3)) } this.timerTick += 1 @@ -270,6 +270,7 @@ func (this *Timer) cascade(tv *[TVN_SIZE]ListHead, index uint32) uint32 { } func (this *Timer) internalAddTimer(timer_list *TimerList) { + timer_list.entry.data = timer_list expires := timer_list.expires idx := expires - this.timerTick var vec *ListHead @@ -308,7 +309,9 @@ func (this *Timer) newTimerList() *TimerList { this.freeTimerNum -= 1 return timerList } else { - return new(TimerList) + timerList := new(TimerList) + timerList.entry.Init() + return timerList } }