1
This commit is contained in:
parent
efc8db84bc
commit
6aa5ba1546
17
app.go
17
app.go
@ -29,9 +29,11 @@ type App_ struct {
|
|||||||
imMsgHandlers [1024]func(int16,*q5.XParams)
|
imMsgHandlers [1024]func(int16,*q5.XParams)
|
||||||
maxRunDelay int64
|
maxRunDelay int64
|
||||||
maxScheduleTime int64
|
maxScheduleTime int64
|
||||||
|
updateFunc func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *App_) Init() {
|
func (this *App_) Init(updateFunc func ()) {
|
||||||
|
this.updateFunc = updateFunc
|
||||||
this.nowTime = time.Now()
|
this.nowTime = time.Now()
|
||||||
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
||||||
_Timer = &q5.Timer{}
|
_Timer = &q5.Timer{}
|
||||||
@ -86,18 +88,13 @@ func (this *App_) Run() {
|
|||||||
beginTick := q5.GetTickCount()
|
beginTick := q5.GetTickCount()
|
||||||
_Timer.Update()
|
_Timer.Update()
|
||||||
this.dispatchIMMsg()
|
this.dispatchIMMsg()
|
||||||
|
this.updateFunc()
|
||||||
|
this.schedule()
|
||||||
endTick := q5.GetTickCount()
|
endTick := q5.GetTickCount()
|
||||||
|
|
||||||
if this.maxRunDelay < endTick - beginTick {
|
if this.maxRunDelay < endTick - beginTick {
|
||||||
this.maxRunDelay = endTick - beginTick
|
this.maxRunDelay = endTick - beginTick
|
||||||
}
|
}
|
||||||
|
|
||||||
this.schedule()
|
|
||||||
endTick = q5.GetTickCount()
|
|
||||||
if this.maxScheduleTime < endTick - beginTick {
|
|
||||||
this.maxScheduleTime = endTick - beginTick
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +169,10 @@ func (this *App_) schedule() {
|
|||||||
this.loopCond.L.Unlock()
|
this.loopCond.L.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *App_) NotifyLoopCond() {
|
||||||
|
this.loopCond.Broadcast()
|
||||||
|
}
|
||||||
|
|
||||||
func (this *App_) NowUnix() int64 {
|
func (this *App_) NowUnix() int64 {
|
||||||
return this.nowUnixNano / int64(time.Second)
|
return this.nowUnixNano / int64(time.Second)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user