This commit is contained in:
aozhiwei 2020-11-13 16:08:42 +08:00
parent ce7a0fd64c
commit af4ce33bde

6
app.go
View File

@ -3,6 +3,7 @@ package f5
import ( import (
"flag" "flag"
"sync" "sync"
"sync/atomic"
"time" "time"
"os" "os"
"q5" "q5"
@ -24,6 +25,7 @@ type App_ struct {
chGoLoopTimerExit chan int chGoLoopTimerExit chan int
chGoLoopWait chan int64 chGoLoopWait chan int64
nowTime time.Time nowTime time.Time
nowUnix int64
imMsgHandlers [1024]func(int16,*q5.XParams) imMsgHandlers [1024]func(int16,*q5.XParams)
maxRunDelay int64 maxRunDelay int64
maxScheduleTime int64 maxScheduleTime int64
@ -31,6 +33,7 @@ type App_ struct {
func (this *App_) Init() { func (this *App_) Init() {
this.nowTime = time.Now() this.nowTime = time.Now()
atomic.StoreInt64(&this.nowUnix, this.nowTime.Unix())
_Timer = &q5.Timer{} _Timer = &q5.Timer{}
_Timer.Init( _Timer.Init(
func (context interface{}) int64 { func (context interface{}) int64 {
@ -78,6 +81,7 @@ func (this *App_) UnInit() {
func (this *App_) Run() { func (this *App_) Run() {
for !this.terminated { for !this.terminated {
this.nowTime = time.Now() this.nowTime = time.Now()
atomic.StoreInt64(&this.nowUnix, this.nowTime.Unix())
beginTick := q5.GetTickCount() beginTick := q5.GetTickCount()
_Timer.Update() _Timer.Update()
@ -169,7 +173,7 @@ func (this *App_) schedule() {
} }
func (this *App_) NowUnix() int64 { func (this *App_) NowUnix() int64 {
return this.nowTime.Unix() return this.nowUnix
} }
func (this *App_) outputRuningLog() { func (this *App_) outputRuningLog() {