This commit is contained in:
aozhiwei 2020-09-04 11:27:47 +08:00
parent 9e16bd764d
commit e934b0c6ca
3 changed files with 12 additions and 6 deletions

2
go.mod
View File

@ -1 +1,3 @@
module q5 module q5
go 1.15

View File

@ -34,6 +34,7 @@ func (this *ListHead) Replace(pnew *ListHead) {
pnew.next = this.next pnew.next = this.next
pnew.next.prev = pnew pnew.next.prev = pnew
pnew.prev = this.prev pnew.prev = this.prev
pnew.prev.next = pnew
pnew.data = this.data pnew.data = this.data
} }

View File

@ -53,12 +53,12 @@ func (this *Timer) Init(
this.getTickCount = getTickCount this.getTickCount = getTickCount
this.gcTime = gcTime this.gcTime = gcTime
this.cacheTimerNum = cacheTimerNum this.cacheTimerNum = cacheTimerNum
/*this.AddRepeatTimer( this.AddRepeatTimer(
this.gcTime, this.gcTime,
func (params *XParams) { func (params *XParams) {
}, },
this.gcTimerFunc)*/ this.gcTimerFunc)
} }
func (this *Timer) UnInit() { func (this *Timer) UnInit() {
@ -151,6 +151,7 @@ func (this *Timer) AddDeadLineTimerEx(
if install_func != nil { if install_func != nil {
install_func(timerList, &timerList.params) install_func(timerList, &timerList.params)
} }
this.ModifyTimer(timerList, milli_seconds)
return timerList return timerList
} }
@ -174,6 +175,7 @@ func (this *Timer) AddRepeatTimerEx(
if install_func != nil { if install_func != nil {
install_func(timerList, &timerList.params) install_func(timerList, &timerList.params)
} }
this.ModifyTimer(timerList, milli_seconds)
return timerList return timerList
} }
@ -197,6 +199,7 @@ func (this *Timer) AddFixedTimerEx(
if install_func != nil { if install_func != nil {
install_func(timerList, &timerList.params) install_func(timerList, &timerList.params)
} }
this.ModifyTimer(timerList, milli_seconds)
return timerList return timerList
} }
@ -279,16 +282,16 @@ func (this *Timer) internalAddTimer(timer_list *TimerList) {
index = (uint32)(expires & TVR_MASK) index = (uint32)(expires & TVR_MASK)
vec = &this.tv1[index] vec = &this.tv1[index]
} else if idx < (1 << (TVR_BITS + TVN_BITS)) { } else if idx < (1 << (TVR_BITS + TVN_BITS)) {
index = (uint32)((expires >> TVR_BITS) & TVR_MASK) index = (uint32)((expires >> TVR_BITS) & TVN_MASK)
vec = &this.tv2[index] vec = &this.tv2[index]
} else if idx < (1 << (TVR_BITS + 2 * TVN_BITS)) { } else if idx < (1 << (TVR_BITS + 2 * TVN_BITS)) {
index = (uint32)((expires >> (TVR_BITS + 1 * TVN_BITS)) & TVR_MASK) index = (uint32)((expires >> (TVR_BITS + 1 * TVN_BITS)) & TVN_MASK)
vec = &this.tv3[index] vec = &this.tv3[index]
} else if idx < (1 << (TVR_BITS + 3 * TVN_BITS)) { } else if idx < (1 << (TVR_BITS + 3 * TVN_BITS)) {
index = (uint32)((expires >> (TVR_BITS + 2 * TVN_BITS)) & TVR_MASK) index = (uint32)((expires >> (TVR_BITS + 2 * TVN_BITS)) & TVN_MASK)
vec = &this.tv4[index] vec = &this.tv4[index]
} else { } else {
index = (uint32)((expires >> (TVR_BITS + 3 * TVN_BITS)) & TVR_MASK) index = (uint32)((expires >> (TVR_BITS + 3 * TVN_BITS)) & TVN_MASK)
vec = &this.tv5[index] vec = &this.tv5[index]
} }
vec.AddTail(&timer_list.entry) vec.AddTail(&timer_list.entry)