class Celluloid::Actor::System
Constants
- ROOT_SERVICES
Attributes
group[R]
registry[R]
Public Class Methods
new()
click to toggle source
# File lib/celluloid/actor/system.rb, line 35 def initialize @tree = nil @group = Celluloid.group_class.new @registry = Internals::Registry.new @root = ROOT_SERVICES end
Public Instance Methods
assert_inactive()
click to toggle source
# File lib/celluloid/actor/system.rb, line 138 def assert_inactive @group.assert_inactive end
clear_registry()
click to toggle source
# File lib/celluloid/actor/system.rb, line 78 def clear_registry @registry.clear end
get_thread() { || ... }
click to toggle source
# File lib/celluloid/actor/system.rb, line 59 def get_thread @group.get do Thread.current[:celluloid_actor_system] = self yield end end
registered()
click to toggle source
# File lib/celluloid/actor/system.rb, line 74 def registered @registry.names end
root_configuration()
click to toggle source
# File lib/celluloid/actor/system.rb, line 31 def root_configuration @root end
root_services()
click to toggle source
the root of the supervisor tree is established at supervision/root
# File lib/celluloid/actor/system.rb, line 27 def root_services @tree end
running()
click to toggle source
# File lib/celluloid/actor/system.rb, line 82 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
running?()
click to toggle source
# File lib/celluloid/actor/system.rb, line 98 def running? @group.active? end
shutdown()
click to toggle source
Shut down all running actors
# File lib/celluloid/actor/system.rb, line 103 def shutdown actors = running Timeout.timeout(shutdown_timeout) do Internals::Logger.debug "Terminating #{actors.size} #{actors.size > 1 ? 'actors' : 'actor'}..." unless actors.empty? # 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
shutdown_timeout()
click to toggle source
# File lib/celluloid/actor/system.rb, line 142 def shutdown_timeout Celluloid.shutdown_timeout end
stack_dump()
click to toggle source
# File lib/celluloid/actor/system.rb, line 66 def stack_dump Internals::Stack::Dump.new(@group) end
stack_summary()
click to toggle source
# File lib/celluloid/actor/system.rb, line 70 def stack_summary Internals::Stack::Summary.new(@group) end
start()
click to toggle source
Launch default services
# File lib/celluloid/actor/system.rb, line 43 def start within do @root = Supervision::Service::Root.define @tree = root_configuration.deploy end true end
within() { || ... }
click to toggle source
# File lib/celluloid/actor/system.rb, line 51 def within old = Thread.current[:celluloid_actor_system] Thread.current[:celluloid_actor_system] = self yield ensure Thread.current[:celluloid_actor_system] = old end