From d9013f408ef82b9619d62508df15258f4973d21f Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 20 Aug 2023 17:55:06 +0800 Subject: [PATCH] 1 --- app.go | 12 +++++++++++- constant.go | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index cbe9ed0..7d9b551 100644 --- a/app.go +++ b/app.go @@ -86,6 +86,12 @@ func (this *app) init(userApp UserApp) { this.loopCond = sync.NewCond(new(sync.Mutex)) this.chGoLoopTimerExit = make(chan int) this.chGoLoopWait = make(chan int64) + _app.RegisterIMMsgHandle( + IM_EXEC_MAIN_THREAD_CB, + func (args q5.Args) { + cb := args[0].(func ()) + cb() + }) this.outputRuningLog() GetSysLog().Info("node_id:%d instance_id:%d pid:%d", this.nodeId, @@ -172,7 +178,11 @@ func (this *app) RegisterIMMsgHandle(msgId uint16, handle func(q5.Args)) { this.imMsgHandlers[msgId] = handle } -func (this *app) RegisterMainThreadCb(func ()) { +func (this *app) RegisterMainThreadCb(cb func ()) { + _app.AddIMMsg(IM_EXEC_MAIN_THREAD_CB, + []interface{} { + cb, + }) } func (this *app) goLoopTimer() { diff --git a/constant.go b/constant.go index 65f4069..15cfbb1 100644 --- a/constant.go +++ b/constant.go @@ -2,6 +2,7 @@ package f5 const ( IM_HTTP_CLI_MGR_RESPONSE = 1 + IM_EXEC_MAIN_THREAD_CB = iota ) const (