# File lib/celluloid/actor/system.rb, line 50 def initialize @tree = nil @group = Celluloid.group_class.new @registry = Internals::Registry.new @root = ROOT_SERVICES end
# File lib/celluloid/actor/system.rb, line 154 def assert_inactive @group.assert_inactive end
# File lib/celluloid/actor/system.rb, line 94 def clear_registry @registry.clear end
# File lib/celluloid/actor/system.rb, line 75 def get_thread @group.get do Thread.current[:celluloid_actor_system] = self yield end end
# File lib/celluloid/actor/system.rb, line 90 def registered @registry.names end
# File lib/celluloid/actor/system.rb, line 46 def root_configuration @root end
the root of the supervisor tree is established at supervision/root
# File lib/celluloid/actor/system.rb, line 42 def root_services @tree end
# File lib/celluloid/actor/system.rb, line 98 def running actors = [] @group.each do |t| next unless t.role == :actor actor = t.actor # NOTE - these are in separate statements, since on JRuby t.actor may # become nil befor .behavior_proxy() is called next unless actor next unless actor.respond_to?(:behavior_proxy) proxy = actor.behavior_proxy actors << proxy end actors end
# File lib/celluloid/actor/system.rb, line 114 def running? @group.active? end
Shut down all running actors
# File lib/celluloid/actor/system.rb, line 119 def shutdown actors = running Timeout.timeout(shutdown_timeout) do Internals::Logger.debug "Terminating #{actors.size} #{(actors.size > 1) ? 'actors' : 'actor'}..." if actors.size > 0 # Actors cannot self-terminate, you must do it for them actors.each do |actor| begin actor.terminate! rescue DeadActorError end end actors.each do |actor| begin Actor.join(actor) rescue DeadActorError end end end rescue Timeout::Error Internals::Logger.error("Couldn't cleanly terminate all actors in #{shutdown_timeout} seconds!") unless RUBY_PLATFORM == "java" || RUBY_ENGINE == "rbx" actors.each do |actor| begin Actor.kill(actor) rescue DeadActorError, MailboxDead end end end ensure @group.shutdown clear_registry end
# File lib/celluloid/actor/system.rb, line 158 def shutdown_timeout Celluloid.shutdown_timeout end
# File lib/celluloid/actor/system.rb, line 82 def stack_dump Internals::Stack::Dump.new(@group) end
# File lib/celluloid/actor/system.rb, line 86 def stack_summary Internals::Stack::Summary.new(@group) end
Launch default services
# File lib/celluloid/actor/system.rb, line 58 def start within do @root = Supervision::Service::Root.define @tree = root_configuration.deploy # de root_services[:group_manager].manage! @group end true end
# File lib/celluloid/actor/system.rb, line 67 def within old = Thread.current[:celluloid_actor_system] Thread.current[:celluloid_actor_system] = self yield ensure Thread.current[:celluloid_actor_system] = old end