diff --git a/cluster/node/actor.go b/cluster/node/actor.go index edf9262..49ff50e 100644 --- a/cluster/node/actor.go +++ b/cluster/node/actor.go @@ -135,10 +135,19 @@ func (a *Actor) Push(uid int64, message *cluster.Message) { // Destroy 销毁Actor func (a *Actor) Destroy() { - if !a.state.CompareAndSwap(started, destroyed) { + if !a.destroy() { return } + a.scheduler.remove(a.Kind(), a.ID()) +} + +// 销毁Actor +func (a *Actor) destroy() bool { + if !a.state.CompareAndSwap(started, destroyed) { + return false + } + a.processor.Destroy() a.scheduler.batchUnbindActor(func(relations map[int64]map[string]*Actor) { @@ -154,6 +163,8 @@ func (a *Actor) Destroy() { close(a.mailbox) close(a.fnChan) + + return true } // 绑定用户 diff --git a/cluster/node/scheduler.go b/cluster/node/scheduler.go index 0639201..9804605 100644 --- a/cluster/node/scheduler.go +++ b/cluster/node/scheduler.go @@ -74,9 +74,7 @@ func (s *Scheduler) kill(kind, id string) bool { return false } - act.Destroy() - - return true + return act.destroy() } // 移除Actor