MCPcopy Create free account
hub / github.com/astercloud/aster / Stop

Method Stop

pkg/actor/system.go:330–346  ·  view source on GitHub ↗

Stop 停止 Actor

(pid *PID)

Source from the content-addressed store, hash-verified

328
329// Stop 停止 Actor
330func (s *System) Stop(pid *PID) {
331 s.actorsMu.RLock()
332 cell, exists := s.actors[pid.ID]
333 s.actorsMu.RUnlock()
334
335 if !exists {
336 return
337 }
338
339 // 发送 PoisonPill
340 s.Send(pid, &PoisonPill{})
341
342 // 等待停止完成
343 cell.stateMu.Lock()
344 cell.state = actorStateStopping
345 cell.stateMu.Unlock()
346}
347
348// StopGracefully 优雅停止 Actor(等待处理完当前消息)
349func (s *System) StopGracefully(pid *PID, timeout time.Duration) error {

Callers 7

TestSystem_ParentChildFunction · 0.95
TestSystem_StopFunction · 0.95
StopGracefullyMethod · 0.95
ShutdownWithTimeoutMethod · 0.95
applyDirectiveMethod · 0.95
cleanupActorMethod · 0.95

Calls 1

SendMethod · 0.95

Tested by 3

TestSystem_ParentChildFunction · 0.76
TestSystem_StopFunction · 0.76