This commit is contained in:
aozhiwei 2020-10-23 11:13:51 +08:00
parent 69d556c643
commit 5df419b966
2 changed files with 17 additions and 4 deletions

16
app.go
View File

@ -1,9 +1,11 @@
package f5
import "flag"
import "sync"
import "time"
import "q5"
import (
"flag"
"sync"
"time"
"q5"
)
type App_ struct {
nodeId int
@ -19,10 +21,12 @@ type App_ struct {
imWorkNode *IMMsgNode
imMsgMutex sync.RWMutex
chGoLoopTimerExit chan int
nowTime time.Time
imMsgHandlers [1024]func(int16,*q5.XParams)
}
func (this *App_) Init() {
this.nowTime = time.Now()
_Timer = &q5.Timer{}
_Timer.Init(
func (context interface{}) int64 {
@ -60,6 +64,7 @@ func (this *App_) UnInit() {
func (this *App_) Run() {
for !this.terminated {
this.nowTime = time.Now()
_Timer.Update()
this.schedule()
}
@ -129,3 +134,6 @@ func (this *App_) schedule() {
this.loopCond.L.Unlock()
}
func (this *App_) NowUnix() int64 {
return this.nowTime.Unix()
}

View File

@ -5,6 +5,7 @@ import "q5"
var App *App_
var _Timer *q5.Timer
var _SysLog *SysLog_
var _TgLog *TGLog_
func Timer() *q5.Timer {
return _Timer
@ -13,3 +14,7 @@ func Timer() *q5.Timer {
func SysLog() *SysLog_ {
return _SysLog
}
func TgLog() *TGLog_ {
return _TgLog
}