Class: Celluloid::ActorSystem

### Home Classes Methods

### In Files

- lib/celluloid/actor_system.rb

### Parent

Object

### Methods

- ::new
- #assert_inactive
- #clear_registry
- #get_thread
- #registered
- #running
- #running?
- #shutdown
- #shutdown_timeout
- #stack_dump
- #start
- #within

### Class/Module Index

Quicksearch

- Celluloid
- Celluloid::AbortError
- Celluloid::AbstractProxy
- Celluloid::Actor
- Celluloid::Actor::Sleeper
- Celluloid::ActorProxy
- Celluloid::ActorSystem
- Celluloid::AsyncCall
- Celluloid::AsyncProxy
- Celluloid::BlockCall
- Celluloid::BlockProxy
- Celluloid::BlockResponse
- Celluloid::CPUCounter
- Celluloid::Call
- Celluloid::CallChain
- Celluloid::Cell
- Celluloid::Cell::ExitHandler
- Celluloid::CellProxy
- Celluloid::ClassMethods
- Celluloid::Condition
- Celluloid::Condition::Waiter
- Celluloid::ConditionError
- Celluloid::DeadTaskError
- Celluloid::ErrorResponse
- Celluloid::EventedMailbox
- Celluloid::ExitEvent
- Celluloid::FSM
- Celluloid::FSM::ClassMethods
- Celluloid::FSM::State
- Celluloid::FSM::UnattachedError
- Celluloid::FiberStackError
- Celluloid::Future
- Celluloid::Future::Result
- Celluloid::FutureProxy
- Celluloid::Handler
- Celluloid::Handlers
- Celluloid::Incident
- Celluloid::IncidentLogger
- Celluloid::IncidentLogger::Severity
- Celluloid::IncidentReporter
- Celluloid::IncidentReporter::Formatter
- Celluloid::InstanceMethods
- Celluloid::InternalPool
- Celluloid::LinkingRequest
- Celluloid::LinkingResponse
- Celluloid::Links
- Celluloid::LogEvent
- Celluloid::Logger
- Celluloid::Logger::WithBacktrace
- Celluloid::Mailbox
- Celluloid::MailboxDead
- Celluloid::MailboxShutdown
- Celluloid::Method
- Celluloid::NamingRequest
- Celluloid::NotTaskError
- Celluloid::Notifications
- Celluloid::Notifications::Fanout
- Celluloid::Notifications::Subscriber
- Celluloid::PoolManager
- Celluloid::Probe
- Celluloid::Properties
- Celluloid::Receiver
- Celluloid::Receivers
- Celluloid::Registry
- Celluloid::Response
- Celluloid::ResumableError
- Celluloid::RingBuffer
- Celluloid::SignalConditionRequest
- Celluloid::Signals
- Celluloid::StackDump
- Celluloid::StackDump::ActorState
- Celluloid::StackDump::CellState
- Celluloid::StackDump::DisplayBacktrace
- Celluloid::StackDump::TaskState
- Celluloid::StackDump::ThreadState
- Celluloid::SuccessResponse
- Celluloid::SupervisionGroup
- Celluloid::SupervisionGroup::Member
- Celluloid::Supervisor
- Celluloid::SyncCall
- Celluloid::SyncProxy
- Celluloid::SystemEvent
- Celluloid::Task
- Celluloid::Task::TerminatedError
- Celluloid::Task::TimeoutError
- Celluloid::TaskFiber
- Celluloid::TaskSet
- Celluloid::TaskThread
- Celluloid::TerminationRequest
- Celluloid::Thread
- Celluloid::ThreadHandle
- Celluloid::UUID
- org
- org::jruby
- org::jruby::ext
- org::jruby::ext::fiber
- org::jruby::ext::fiber::ThreadFiber
- Bar
- Baz
- Blocker
- ExampleActorClass
- ExampleCrash
- ExampleMailbox
- ExampleProxy
- ExampleTask
- Fiber
- Foo
- MockActor
- Object
- Thread

No matching classes.

# Celluloid::ActorSystem

### Attributes

registry[R]

### Public Class Methods

new() click to toggle source

    # File lib/celluloid/actor_system.rb, line 5
    def initialize
      @internal_pool = InternalPool.new
      @registry      = Registry.new
    end

### Public Instance Methods

assert_inactive() click to toggle source

    # File lib/celluloid/actor_system.rb, line 99
    def assert_inactive
      @internal_pool.assert_inactive
    end

clear_registry() click to toggle source

    # File lib/celluloid/actor_system.rb, line 46
    def clear_registry
      @registry.clear
    end

get_thread() click to toggle source

    # File lib/celluloid/actor_system.rb, line 29
    def get_thread
      @internal_pool.get do
        Thread.current[:celluloid_actor_system] = self
        yield
      end
    end

registered() click to toggle source

    # File lib/celluloid/actor_system.rb, line 42
    def registered
      @registry.names
    end

running() click to toggle source

    # File lib/celluloid/actor_system.rb, line 50
    def running
      actors = []
      @internal_pool.each do |t|
        next unless t.role == :actor
        actors << t.actor.behavior_proxy if t.actor && t.actor.respond_to?(:behavior_proxy)
      end
      actors
    end

running?() click to toggle source

    # File lib/celluloid/actor_system.rb, line 59
    def running?
      @internal_pool.running?
    end

shutdown() click to toggle source

Shut down all running actors

    # File lib/celluloid/actor_system.rb, line 64
    def shutdown
      actors = running
      Timeout.timeout(shutdown_timeout) do
        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

        @internal_pool.shutdown
      end
    rescue Timeout::Error
      Logger.error("Couldn't cleanly terminate all actors in #{shutdown_timeout} seconds!")
      actors.each do |actor|
        begin
          Actor.kill(actor)
        rescue DeadActorError, MailboxDead
        end
      end
    ensure
      @internal_pool.kill
      clear_registry
    end

shutdown_timeout() click to toggle source

    # File lib/celluloid/actor_system.rb, line 103
    def shutdown_timeout
      Celluloid.shutdown_timeout
    end

stack_dump() click to toggle source

    # File lib/celluloid/actor_system.rb, line 36
    def stack_dump
      Celluloid::StackDump.new(@internal_pool)
    end

start() click to toggle source

Launch default services FIXME: We should set up the supervision hierarchy here

    # File lib/celluloid/actor_system.rb, line 13
    def start
      within do
        Celluloid::Notifications::Fanout.supervise_as :notifications_fanout
        Celluloid::IncidentReporter.supervise_as :default_incident_reporter, STDERR
      end
      true
    end

within() click to toggle source

    # File lib/celluloid/actor_system.rb, line 21
    def within
      old = Thread.current[:celluloid_actor_system]
      Thread.current[:celluloid_actor_system] = self
      yield
    ensure
      Thread.current[:celluloid_actor_system] = old
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.