class Celluloid::ActorProxy - celluloid-0.15.2 Documentation

# class Celluloid::ActorProxy

A proxy object returned from Celluloid::Actor.new/new_link which converts the normal Ruby method protocol into an inter-actor message protocol

### Attributes

thread[R]

### Public Class Methods

new(actor) click to toggle source
Calls superclass method

    # File lib/celluloid/proxies/actor_proxy.rb, line 10
    def initialize(actor)
      @thread = actor.thread

      super(actor.mailbox, actor.subject.class.to_s)
      @sync_proxy   = SyncProxy.new(@mailbox, @klass)
      @async_proxy  = AsyncProxy.new(@mailbox, @klass)
      @future_proxy = FutureProxy.new(@mailbox, @klass)
    end

### Public Instance Methods

__class__() click to toggle source

Used for reflecting on proxy objects themselves

    # File lib/celluloid/proxies/actor_proxy.rb, line 8
    def __class__; ActorProxy; end

_send_(meth, *args, &block) click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 19
    def _send_(meth, *args, &block)
      method_missing :__send__, meth, *args, &block
    end

alive?() click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 33
    def alive?
      @mailbox.alive?
    end

async(method_name = nil, *args, &block) click to toggle source

Obtain an async proxy or explicitly invoke a named async method

    # File lib/celluloid/proxies/actor_proxy.rb, line 40
    def async(method_name = nil, *args, &block)
      if method_name
        @async_proxy.method_missing method_name, *args, &block
      else
        @async_proxy
      end
    end

future(method_name = nil, *args, &block) click to toggle source

Obtain a future proxy or explicitly invoke a named future method

    # File lib/celluloid/proxies/actor_proxy.rb, line 49
    def future(method_name = nil, *args, &block)
      if method_name
        @future_proxy.method_missing method_name, *args, &block
      else
        @future_proxy
      end
    end

inspect() click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 23
    def inspect
      method_missing :inspect
    rescue DeadActorError
      "#<Celluloid::ActorProxy(#{@klass}) dead>"
    end

method(name) click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 29
    def method(name)
      Method.new(self, name)
    end

terminate() click to toggle source

Terminate the associated actor

    # File lib/celluloid/proxies/actor_proxy.rb, line 58
    def terminate
      terminate!
      Actor.join(self)
      nil
    end

terminate!() click to toggle source

Terminate the associated actor asynchronously

    # File lib/celluloid/proxies/actor_proxy.rb, line 65
    def terminate!
      ::Kernel.raise DeadActorError, "actor already terminated" unless alive?
      @mailbox << TerminationRequest.new
    end