module exit error

This commit is contained in:
cgc1983
2022-06-09 11:32:25 +08:00
parent e5ceaa9e76
commit 7fe73e55fb

View File

@@ -2,14 +2,16 @@ package service
import ( import (
"fmt" "fmt"
"reflect"
"sync/atomic"
"time"
"github.com/duanhf2012/origin/event" "github.com/duanhf2012/origin/event"
"github.com/duanhf2012/origin/log" "github.com/duanhf2012/origin/log"
rpcHandle "github.com/duanhf2012/origin/rpc" rpcHandle "github.com/duanhf2012/origin/rpc"
"github.com/duanhf2012/origin/util/timer" "github.com/duanhf2012/origin/util/timer"
"reflect"
"sync/atomic"
"time"
) )
const InitModuleId = 1e9 const InitModuleId = 1e9
type IModule interface { type IModule interface {
@@ -123,8 +125,8 @@ func (m *Module) ReleaseModule(moduleId uint32){
m.ReleaseModule(id) m.ReleaseModule(id)
} }
pModule.GetEventHandler().Destroy()
pModule.self.OnRelease() pModule.self.OnRelease()
pModule.GetEventHandler().Destroy()
log.SDebug("Release module ", pModule.GetModuleName()) log.SDebug("Release module ", pModule.GetModuleName())
for pTimer := range pModule.mapActiveTimer { for pTimer := range pModule.mapActiveTimer {
pTimer.Cancel() pTimer.Cancel()
@@ -155,6 +157,7 @@ func (m *Module) NewModuleId() uint32{
} }
var timerSeedId uint32 var timerSeedId uint32
func (m *Module) GenTimerId() uint64 { func (m *Module) GenTimerId() uint64 {
for { for {
newTimerId := (uint64(m.GetModuleId()) << 32) | uint64(atomic.AddUint32(&timerSeedId, 1)) newTimerId := (uint64(m.GetModuleId()) << 32) | uint64(atomic.AddUint32(&timerSeedId, 1))
@@ -166,7 +169,6 @@ func (m *Module) GenTimerId() uint64{
} }
} }
func (m *Module) GetAncestor() IModule { func (m *Module) GetAncestor() IModule {
return m.ancestor return m.ancestor
} }
@@ -287,8 +289,6 @@ func (m *Module) CancelTimerId(timerId *uint64) bool{
return true return true
} }
func (m *Module) OnRelease() { func (m *Module) OnRelease() {
} }