Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support a root supervisor

  • Loading branch information...
commit 8cfe0eae29c1e9d836450df4f858b5d4dd7ccdbf 1 parent 1fe557c
@tarcieri tarcieri authored
Showing with 14 additions and 6 deletions.
  1. +4 −1 lib/celluloid.rb
  2. +10 −5 lib/celluloid/supervisor.rb
View
5 lib/celluloid.rb
@@ -73,8 +73,11 @@ def shutdown
actors = Actor.all
Logger.info "Terminating #{actors.size} actors..." if actors.size > 0
+ # Attempt to shut down the supervision tree, if available
+ Supervisor.root.terminate if Supervisor.root
+
# Actors cannot self-terminate, you must do it for them
- terminators = actors.each do |actor|
+ terminators = Actor.all.each do |actor|
begin
actor.future(:terminate)
rescue DeadActorError, MailboxError
View
15 lib/celluloid/supervisor.rb
@@ -8,12 +8,17 @@ class Supervisor
# Retrieve the actor this supervisor is supervising
attr_reader :actor
- def self.supervise(klass, *args, &block)
- new(nil, klass, *args, &block)
- end
+ class << self
+ # Define the root of the supervision tree
+ attr_accessor :root
+
+ def supervise(klass, *args, &block)
+ new(nil, klass, *args, &block)
+ end
- def self.supervise_as(name, klass, *args, &block)
- new(name, klass, *args, &block)
+ def supervise_as(name, klass, *args, &block)
+ new(name, klass, *args, &block)
+ end
end
def initialize(name, klass, *args, &block)
Please sign in to comment.
Something went wrong with that request. Please try again.