新增模块动态运行功能

This commit is contained in:
boyce
2019-02-18 10:43:11 +08:00
parent bc82d200b0
commit e3e16eefb4

View File

@@ -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)