Class: Celluloid::Cell

### Home Classes Methods

### In Files

- lib/celluloid/cell.rb

### Parent

Object

### Namespace

- CLASS Celluloid::Cell::ExitHandler

### Methods

- ::new
- #invoke
- #shutdown
- #task

### 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::Cell

Wrap the given subject with an Cell

### Attributes

proxy[R]
subject[R]

### Public Class Methods

new(subject, options, actor_options) click to toggle source

    # File lib/celluloid/cell.rb, line 20
    def initialize(subject, options, actor_options)
      @actor                      = Actor.new(self, actor_options)
      @subject                    = subject
      @receiver_block_executions  = options[:receiver_block_executions]
      @exclusive_methods          = options[:exclusive_methods]
      @finalizer                  = options[:finalizer]

      @subject.instance_variable_set(OWNER_IVAR, @actor)

      if exit_handler_name = options[:exit_handler_name]
        @actor.exit_handler = ExitHandler.new(self, @subject, exit_handler_name)
      end

      @actor.handle(Call) do |message|
        invoke(message)
      end
      @actor.handle(BlockCall) do |message|
        task(:invoke_block) { message.dispatch }
      end
      @actor.handle(BlockResponse, Response) do |message|
        message.dispatch
      end

      @actor.start
      @proxy = (options[:proxy_class] || CellProxy).new(@actor.proxy, @actor.mailbox, @subject.class.to_s)
    end

### Public Instance Methods

invoke(call) click to toggle source

    # File lib/celluloid/cell.rb, line 48
    def invoke(call)
      meth = call.method
      if meth == :__send__
        meth = call.arguments.first
      end
      if @receiver_block_executions && meth
        if @receiver_block_executions.include?(meth.to_sym)
          call.execute_block_on_receiver
        end
      end

      task(:call, meth, :dangerous_suspend => meth == :initialize) {
        call.dispatch(@subject)
      }
    end

shutdown() click to toggle source

Run the user-defined finalizer, if one is set

    # File lib/celluloid/cell.rb, line 77
    def shutdown
      return unless @finalizer && @subject.respond_to?(@finalizer, true)

      task(:finalizer, @finalizer, :dangerous_suspend => true) do
        begin
          @subject.__send__(@finalizer)
        rescue => ex
          Logger.crash("#{@subject.class} finalizer crashed!", ex)
        end
      end
    end

task(task_type, method_name = nil, meta = nil, &block) click to toggle source

    # File lib/celluloid/cell.rb, line 64
    def task(task_type, method_name = nil, meta = nil, &block)
      meta ||= {}
      meta.merge!(:method_name => method_name)
      @actor.task(task_type, meta) do
        if @exclusive_methods && method_name && @exclusive_methods.include?(method_name.to_sym)
          Celluloid.exclusive { yield }
        else
          yield
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.