f5/timer.go
2023-08-13 12:11:02 +08:00

100 lines
2.2 KiB
Go

package f5
import (
"q5"
)
type TimerWp struct {
*q5.XTimerWp
}
type TimerAttacher struct {
*q5.XTimerAttacher
}
type Timer struct {
timer *q5.XTimer
}
func (this *Timer) init() {
this.timer = new(q5.XTimer)
this.timer.Init(
func (context interface{}) int64 {
return q5.GetTickCount()
},
nil,
1000 * 60,
5000)
}
func (this *Timer) update() {
this.timer.Update()
}
func (this *Timer) unInit() {
this.timer.UnInit()
this.timer = nil
}
func (this *Timer) NewTimerAttacher() *TimerAttacher {
ac := TimerAttacher{}
ac.XTimerAttacher = this.timer.NewTimerAttacher()
return &ac
}
func (this *Timer) SetTimeout(expireTime int32, cb q5.TimerCb) {
this.timer.SetTimeout(expireTime, cb)
}
func (this *Timer) SetTimeoutEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
this.timer.SetTimeoutEx(expireTime, cb, ac.XTimerAttacher)
}
func (this *Timer) SetTimeoutWp(expireTime int32, cb q5.TimerCb) *TimerWp {
wp := TimerWp{}
wp.XTimerWp = this.timer.SetTimeoutWp(expireTime, cb)
return &wp
}
func (this *Timer) SetTimeoutExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
wp := TimerWp{}
wp.XTimerWp = this.timer.SetTimeoutExWp(expireTime, cb, ac.XTimerAttacher)
return &wp
}
func (this *Timer) SetInterval(expireTime int32, cb q5.TimerCb) {
this.timer.SetInterval(expireTime, cb)
}
func (this *Timer) SetIntervalEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
this.timer.SetIntervalEx(expireTime, cb, ac.XTimerAttacher)
}
func (this *Timer) SetIntervalWp(expireTime int32, cb q5.TimerCb) *TimerWp {
wp := TimerWp{}
wp.XTimerWp = this.timer.SetIntervalWp(expireTime, cb)
return &wp
}
func (this *Timer) SetIntervalExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
wp := TimerWp{}
wp.XTimerWp = this.timer.SetIntervalExWp(expireTime, cb, ac.XTimerAttacher)
return &wp
}
func (this *Timer) GetIdleTime() int64 {
return this.timer.GetIdleTime()
}
func (this *Timer) ModifyTimer(timerWp *TimerWp, expireTime int32) {
this.timer.ModifyTimer(timerWp.XTimerWp, expireTime)
}
func (this *Timer) Delete(timerWp *TimerWp) {
this.timer.Delete(timerWp.XTimerWp)
}
func (this *Timer) GetRemainTime(timerWp *TimerWp) int64 {
return this.timer.GetRemainTime(timerWp.XTimerWp)
}