From b0cdc469206356e34185c4283706d62d1f3ec5b1 Mon Sep 17 00:00:00 2001 From: boyce Date: Thu, 4 Apr 2019 20:23:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A8=E6=80=81=E5=8A=A0?= =?UTF-8?q?=E8=BD=BDmodule=E5=87=BA=E7=8E=B0=E9=94=81=E8=A2=AB=E9=87=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/Module.go | 9 ++------- service/Service.go | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/service/Module.go b/service/Module.go index d22f5a1..cee5404 100644 --- a/service/Module.go +++ b/service/Module.go @@ -51,7 +51,7 @@ type BaseModule struct { CurrMaxModuleId uint32 corouterstatus int32 //0表示运行状态 //1释放消亡状态 - rwModuleLocker *sync.RWMutex + rwModuleLocker *sync.Mutex ExitChan chan bool WaitGroup *sync.WaitGroup bInit bool @@ -71,7 +71,7 @@ func (slf *BaseModule) GetRoot() IModule { } } -func (slf *BaseModule) getLocker() *sync.RWMutex { +func (slf *BaseModule) getLocker() *sync.Mutex { return slf.rwModuleLocker } @@ -181,11 +181,6 @@ func (slf *BaseModule) AddModule(module IModule) uint32 { return 0 } - if slf.IsRoot() { - //构建Root结点 - slf.rwModuleLocker = &sync.RWMutex{} - } - pModule := slf.GetModuleById(module.GetModuleId()) if pModule != nil { GetLogger().Printf(LEVER_ERROR, "%T Cannot AddModule %T,moduleid %d is repeat!", slf.GetSelf(), module.GetSelf(), module.GetModuleId()) diff --git a/service/Service.go b/service/Service.go index 0029352..f08791d 100644 --- a/service/Service.go +++ b/service/Service.go @@ -2,6 +2,7 @@ package service import ( "fmt" + "sync" "reflect" "strings" @@ -80,5 +81,7 @@ func (slf *BaseService) Init(iservice IService) error { } slf.serviceid = InstanceServiceMgr().GenServiceID() + slf.BaseModule.rwModuleLocker = &sync.Mutex{} + return nil }