1
This commit is contained in:
parent
51f179c1de
commit
ed3e640b8e
13
app.go
13
app.go
@ -12,12 +12,13 @@ type App_ struct {
|
||||
flags map[int32]int32
|
||||
servicing bool
|
||||
contextHash map[int32]q5.XParams
|
||||
loopCond sync.Cond
|
||||
loopCond *sync.Cond
|
||||
imTopNode *IMMsgNode
|
||||
imBotNode *IMMsgNode
|
||||
imWorkNode *IMMsgNode
|
||||
imMsgMutex sync.RWMutex
|
||||
chGoLoopTimerExit chan int
|
||||
imMsgHandlers [1024]func(int16,*q5.XParams)
|
||||
}
|
||||
|
||||
func (this *App_) Init() {
|
||||
@ -30,6 +31,7 @@ func (this *App_) Init() {
|
||||
flag.IntVar(&this.nodeId, "n", 0, "node id")
|
||||
flag.IntVar(&this.instanceId, "i", 0, "instance id")
|
||||
flag.Parse()
|
||||
this.loopCond = sync.NewCond(new(sync.Mutex))
|
||||
this.chGoLoopTimerExit = make(chan int)
|
||||
go this.goLoopTimer()
|
||||
}
|
||||
@ -43,7 +45,7 @@ func (this *App_) UnInit() {
|
||||
func (this *App_) Run() {
|
||||
for !this.terminated {
|
||||
_Timer.Update()
|
||||
this.loopCond.Wait()
|
||||
this.schedule()
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +86,7 @@ func (this *App_) AddIMMsg(msgId int16, params *q5.XParams) {
|
||||
}
|
||||
|
||||
func (this *App_) RegisterIMMsgHandle(msgId int16, handle func(int16,*q5.XParams)) {
|
||||
this.imMsgHandlers[msgId] = handle
|
||||
}
|
||||
|
||||
func (this *App_) goLoopTimer() {
|
||||
@ -96,3 +99,9 @@ func (this *App_) goLoopTimer() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *App_) schedule() {
|
||||
this.loopCond.L.Lock()
|
||||
this.loopCond.Wait()
|
||||
this.loopCond.L.Unlock()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user