From e3e16eefb48af20ba0c7e53b77773fdd1be08592 Mon Sep 17 00:00:00 2001 From: boyce Date: Mon, 18 Feb 2019 10:43:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=BF=90=E8=A1=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/Service.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/service/Service.go b/service/Service.go index b73fcbd..760000c 100644 --- a/service/Service.go +++ b/service/Service.go @@ -20,6 +20,7 @@ type MethodInfo struct { type IModule interface { SetModuleType(moduleType uint32) GetModuleType() uint32 + DynamicRun(module IModule) RunModule(module IModule, exit chan bool, pwaitGroup *sync.WaitGroup) error InitModule(module IModule) error OnInit() error @@ -79,6 +80,9 @@ type BaseModule struct { ownerService IService tickTime int64 + + exit chan bool + pwaitGroup *sync.WaitGroup } func (slf *BaseService) GetServiceId() int { @@ -217,7 +221,14 @@ func (slf *BaseModule) InitModule(module IModule) error { return nil } +func (slf *BaseModule) DynamicRun(module IModule) { + module.InitModule(module) + module.RunModule(module, slf.exit, slf.pwaitGroup) +} + func (slf *BaseModule) RunModule(module IModule, exit chan bool, pwaitGroup *sync.WaitGroup) error { + slf.exit = exit + slf.pwaitGroup = pwaitGroup //运行所有子模块 for _, subModule := range slf.mapModule { go subModule.RunModule(subModule, exit, pwaitGroup)