This commit is contained in:
azw 2023-08-13 12:39:46 +08:00
parent 9315d393ce
commit 3ce0f6af2b
3 changed files with 13 additions and 31 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"time"
"fmt"
"sync"
"q5"
"f5"
@ -12,19 +11,17 @@ import (
)
type App struct {
msgMutex sync.Mutex
msgList q5.ListHead
workList q5.ListHead
netMsgQueue q5.Queue
}
var app = new (App)
func (this *App) GetPkgName() string {
return "imserver"
}
func (this *App) Init() {
//f5.App = &this.F5App
//f5.App.SetPkgName("imserver")
//this.F5App.Init(this.Update)
this.msgList.Init(nil)
this.workList.Init(nil)
this.netMsgQueue.Init()
f5.LoadMetaTable(mt.Table)
fmt.Println("listen_port", mt.Table.IMServer.GetById(0).GetListenPort())
@ -36,19 +33,12 @@ func (this *App) Init() {
func (this *App) UnInit() {
handlerMgr.UnInit()
wspListener.UnInit()
//this.F5App.UnInit()
}
func (this *App) Update() {
if this.workList.Empty() {
this.msgMutex.Lock()
defer this.msgMutex.Unlock()
if !this.msgList.Empty() {
this.msgList.ReplaceInit(&this.workList)
}
}
for !this.workList.Empty() {
next := this.workList.Next()
this.netMsgQueue.Fetch()
for !this.netMsgQueue.WorkList.Empty() {
next := this.netMsgQueue.WorkList.Next()
hdr, ok := next.GetData().(*f5.MsgHdr)
if ok {
handler := cs.GetNetMsgHandler(hdr.MsgId)
@ -83,14 +73,6 @@ func (this *App) goReportServerState() {
}
func (this *App) addNetMsg(hdr *f5.MsgHdr) {
{
this.msgMutex.Lock()
defer this.msgMutex.Unlock()
this.msgList.AddTail(&hdr.Entry);
}
//this.NotifyLoopCond()
}
func (this *App) GetPkgName() string {
return "imserver"
this.netMsgQueue.Push(&hdr.Entry)
f5.GetApp().NotifyLoopCond()
}

View File

@ -10,7 +10,7 @@ type table struct {
var Table = f5.New(func (this* table) {
this.IMServer = f5.New(func (this *IMServerTable) {
this.FileName = "imserver.cluster.json"
this.FileName = "../config/imserver.cluster.json"
this.PrimKey = ""
});
})

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 7bffd9a638a1888f22f68a8b191bc9e4b54e3e99
Subproject commit aecf26a45c74547bb724f59653331dcc34f16974