class Celluloid::ActorProxy - celluloid-0.16.0 Documentation

# class Celluloid::ActorProxy

A proxy which controls the Actor lifecycle

### Attributes

mailbox[R]
thread[R]

### Public Class Methods

new(thread, mailbox) click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 9
    def initialize(thread, mailbox)
      @thread = thread
      @mailbox = mailbox
    end

### Public Instance Methods

__class__() click to toggle source

Used for reflecting on proxy objects themselves

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

alive?() click to toggle source

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

inspect() click to toggle source

    # File lib/celluloid/proxies/actor_proxy.rb, line 14
    def inspect
      # TODO: use a system event to fetch actor state: tasks?
      "#<Celluloid::ActorProxy(#{@mailbox.address}) alive>"
    rescue DeadActorError
      "#<Celluloid::ActorProxy(#{@mailbox.address}) dead>"
    end

terminate() click to toggle source

Terminate the associated actor

    # File lib/celluloid/proxies/actor_proxy.rb, line 26
    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 33
    def terminate!
      ::Kernel.raise DeadActorError, "actor already terminated" unless alive?
      @mailbox << TerminationRequest.new
    end