mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
新增模块动态运行功能
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user