1
This commit is contained in:
parent
2660a713e4
commit
57695a25f4
14
app.go
14
app.go
@ -59,15 +59,7 @@ func (this *app) init(userApp UserApp) {
|
|||||||
this.nowTime = time.Now()
|
this.nowTime = time.Now()
|
||||||
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
||||||
_Timer = &Timer{}
|
_Timer = &Timer{}
|
||||||
/*
|
_Timer.init()
|
||||||
_Timer.Init(
|
|
||||||
func (context interface{}) int64 {
|
|
||||||
return q5.GetTickCount()
|
|
||||||
},
|
|
||||||
nil,
|
|
||||||
1000 * 60,
|
|
||||||
5000)
|
|
||||||
*/
|
|
||||||
_SysLog = new(SysLog_)
|
_SysLog = new(SysLog_)
|
||||||
_SysLog.Init()
|
_SysLog.Init()
|
||||||
_TgLog = new(TGLog_)
|
_TgLog = new(TGLog_)
|
||||||
@ -95,7 +87,7 @@ func (this *app) init(userApp UserApp) {
|
|||||||
|
|
||||||
func (this *app) unInit() {
|
func (this *app) unInit() {
|
||||||
this.chGoLoopTimerExit <- 1
|
this.chGoLoopTimerExit <- 1
|
||||||
//_Timer.UnInit()
|
_Timer.unInit()
|
||||||
_Timer = nil
|
_Timer = nil
|
||||||
this.userApp.UnInit()
|
this.userApp.UnInit()
|
||||||
}
|
}
|
||||||
@ -106,7 +98,7 @@ func (this *app) run() {
|
|||||||
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
||||||
|
|
||||||
beginTick := q5.GetTickCount()
|
beginTick := q5.GetTickCount()
|
||||||
_Timer.Update()
|
_Timer.update()
|
||||||
this.dispatchIMMsg()
|
this.dispatchIMMsg()
|
||||||
this.userApp.Update()
|
this.userApp.Update()
|
||||||
this.schedule()
|
this.schedule()
|
||||||
|
46
timer.go
46
timer.go
@ -9,23 +9,43 @@ type TimerWp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TimerAttacher struct {
|
type TimerAttacher struct {
|
||||||
q5.XTimerAttacher
|
*q5.XTimerAttacher
|
||||||
}
|
}
|
||||||
|
|
||||||
type Timer struct {
|
type Timer struct {
|
||||||
timer *q5.XTimer
|
timer *q5.XTimer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) Update() {
|
func (this *Timer) init() {
|
||||||
|
this.timer.Init(
|
||||||
|
func (context interface{}) int64 {
|
||||||
|
return q5.GetTickCount()
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
1000 * 60,
|
||||||
|
5000)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Timer) update() {
|
||||||
this.timer.Update()
|
this.timer.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Timer) unInit() {
|
||||||
|
this.timer.UnInit()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Timer) NewTimerAttacher() *TimerAttacher {
|
||||||
|
ac := TimerAttacher{}
|
||||||
|
ac.XTimerAttacher = this.timer.NewTimerAttacher()
|
||||||
|
return &ac
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Timer) SetTimeout(expireTime int32, cb q5.TimerCb) {
|
func (this *Timer) SetTimeout(expireTime int32, cb q5.TimerCb) {
|
||||||
this.timer.SetTimeout(expireTime, cb)
|
this.timer.SetTimeout(expireTime, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) SetTimeoutEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
|
func (this *Timer) SetTimeoutEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
|
||||||
this.timer.SetTimeoutEx(expireTime, cb, &ac.XTimerAttacher)
|
this.timer.SetTimeoutEx(expireTime, cb, ac.XTimerAttacher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) SetTimeoutWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
func (this *Timer) SetTimeoutWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
||||||
@ -36,7 +56,7 @@ func (this *Timer) SetTimeoutWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
|||||||
|
|
||||||
func (this *Timer) SetTimeoutExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
|
func (this *Timer) SetTimeoutExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
|
||||||
wp := TimerWp{}
|
wp := TimerWp{}
|
||||||
wp.XTimerWp = this.timer.SetTimeoutExWp(expireTime, cb, &ac.XTimerAttacher)
|
wp.XTimerWp = this.timer.SetTimeoutExWp(expireTime, cb, ac.XTimerAttacher)
|
||||||
return &wp
|
return &wp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +65,7 @@ func (this *Timer) SetInterval(expireTime int32, cb q5.TimerCb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) SetIntervalEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
|
func (this *Timer) SetIntervalEx(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) {
|
||||||
this.timer.SetIntervalEx(expireTime, cb, &ac.XTimerAttacher)
|
this.timer.SetIntervalEx(expireTime, cb, ac.XTimerAttacher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) SetIntervalWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
func (this *Timer) SetIntervalWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
||||||
@ -56,10 +76,22 @@ func (this *Timer) SetIntervalWp(expireTime int32, cb q5.TimerCb) *TimerWp {
|
|||||||
|
|
||||||
func (this *Timer) SetIntervalExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
|
func (this *Timer) SetIntervalExWp(expireTime int32, cb q5.TimerCb, ac *TimerAttacher) *TimerWp {
|
||||||
wp := TimerWp{}
|
wp := TimerWp{}
|
||||||
wp.XTimerWp = this.timer.SetIntervalExWp(expireTime, cb, &ac.XTimerAttacher)
|
wp.XTimerWp = this.timer.SetIntervalExWp(expireTime, cb, ac.XTimerAttacher)
|
||||||
return &wp
|
return &wp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Timer) GetIdleTime() int64 {
|
func (this *Timer) GetIdleTime() int64 {
|
||||||
return this.GetIdleTime()
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user