This commit is contained in:
aozhiwei 2023-08-12 19:05:12 +08:00
parent b1b47302a3
commit 1e0148bd50
4 changed files with 32 additions and 43 deletions

30
app.go
View File

@ -16,7 +16,7 @@ type App_ struct {
pkgName string pkgName string
flags map[int32]int32 flags map[int32]int32
servicing bool servicing bool
contextHash map[int32]q5.XParams contextHash map[int32]q5.Args
loopCond *sync.Cond loopCond *sync.Cond
imTopNode *IMMsgNode imTopNode *IMMsgNode
imBotNode *IMMsgNode imBotNode *IMMsgNode
@ -26,7 +26,7 @@ type App_ struct {
chGoLoopWait chan int64 chGoLoopWait chan int64
nowTime time.Time nowTime time.Time
nowUnixNano int64 nowUnixNano int64
imMsgHandlers [1024]func(int16,*q5.XParams) imMsgHandlers [1024]func(int16, q5.Args)
maxRunDelay int64 maxRunDelay int64
maxScheduleTime int64 maxScheduleTime int64
updateFunc func () updateFunc func ()
@ -36,22 +36,11 @@ func (this *App_) Init(updateFunc func ()) {
this.updateFunc = updateFunc 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.XTimer{}
_Timer.Init( _Timer.Init(
func (context interface{}) int64 { func (context interface{}) int64 {
return q5.GetTickCount() return q5.GetTickCount()
}, },
func (context interface{}, isFirstAdd bool, milliSeconds int32, tick int64) int64 {
nowTime := time.Now().Unix()
todayPassedSeconds := nowTime - q5.GetDaySeconds(nowTime)
expires := (tick - todayPassedSeconds * 1000) + int64(milliSeconds)
if isFirstAdd {
if expires <= tick {
expires += 1000 * 3600 * 24
}
}
return expires
},
nil, nil,
1000 * 60, 1000 * 60,
5000) 5000)
@ -123,7 +112,7 @@ func (this *App_) HasFlag(flag int32) bool {
return ok return ok
} }
func (this *App_) AddIMMsg(msgId int16, params *q5.XParams) { func (this *App_) AddIMMsg(msgId int16, params q5.Args) {
p := new(IMMsgNode) p := new(IMMsgNode)
p.msgId = msgId p.msgId = msgId
p.params = params p.params = params
@ -141,7 +130,7 @@ func (this *App_) AddIMMsg(msgId int16, params *q5.XParams) {
this.loopCond.Broadcast() this.loopCond.Broadcast()
} }
func (this *App_) RegisterIMMsgHandle(msgId int16, handle func(int16,*q5.XParams)) { func (this *App_) RegisterIMMsgHandle(msgId int16, handle func(int16,q5.Args)) {
this.imMsgHandlers[msgId] = handle this.imMsgHandlers[msgId] = handle
} }
@ -208,15 +197,14 @@ func (this *App_) dispatchIMMsg() {
} }
func (this *App_) installTimer() { func (this *App_) installTimer() {
Timer().AddRepeatTimer(1000 * 60, Timer().SetInterval(1000 * 60,
func (params* q5.XParams) { func (ev int32, params *q5.Args) {
if ev == q5.TIMER_EXEC_EVENT {
},
func (params* q5.XParams) {
SysLog().Info("max_run_delay:%d max_schedule_time:%d", SysLog().Info("max_run_delay:%d max_schedule_time:%d",
App.maxRunDelay, App.maxRunDelay,
App.maxScheduleTime) App.maxScheduleTime)
App.maxRunDelay = 0 App.maxRunDelay = 0
App.maxScheduleTime = 0 App.maxScheduleTime = 0
}
}) })
} }

View File

@ -3,11 +3,11 @@ package f5
import "q5" import "q5"
var App *App_ var App *App_
var _Timer *q5.Timer var _Timer *q5.XTimer
var _SysLog *SysLog_ var _SysLog *SysLog_
var _TgLog *TGLog_ var _TgLog *TGLog_
func Timer() *q5.Timer { func Timer() *q5.XTimer {
return _Timer return _Timer
} }

View File

@ -42,12 +42,11 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
}) })
SysLog().Info("HttpServer.Init") SysLog().Info("HttpServer.Init")
if logOutputTime > 0 { if logOutputTime > 0 {
Timer().AddRepeatTimer( Timer().SetInterval(
logOutputTime, logOutputTime,
func (params* q5.XParams) { func (ev int32, params *q5.Args) {
params.Sender.SetString(serviceName) if ev == q5.TIMER_EXEC_EVENT {
}, /*
func (params* q5.XParams) {
SysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d", SysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d",
params.Sender.GetString(), params.Sender.GetString(),
this.maxHandleTime, this.maxHandleTime,
@ -57,6 +56,8 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
this.maxHandleTime = 0 this.maxHandleTime = 0
this.okTimes = 0 this.okTimes = 0
this.pageNotFoundTimes = 0 this.pageNotFoundTimes = 0
*/
}
}) })
} }
return this return this

View File

@ -17,7 +17,7 @@ type MsgNode struct {
type IMMsgNode struct { type IMMsgNode struct {
msgId int16 msgId int16
params *q5.XParams params q5.Args
next *IMMsgNode next *IMMsgNode
} }