class Celluloid::FutureProxy

A proxy which creates future calls to an actor

Attributes

mailbox[R]

Public Class Methods

new(mailbox, klass) click to toggle source
# File lib/celluloid/proxies/future_proxy.rb, line 9
def initialize(mailbox, klass)
  @mailbox, @klass = mailbox, klass
end

Public Instance Methods

__class__() click to toggle source

Used for reflecting on proxy objects themselves

# File lib/celluloid/proxies/future_proxy.rb, line 7
def __class__; FutureProxy; end
inspect() click to toggle source
# File lib/celluloid/proxies/future_proxy.rb, line 13
def inspect
  "#<Celluloid::FutureProxy(#{@klass})>"
end
method_missing(meth, *args, &block) click to toggle source
# File lib/celluloid/proxies/future_proxy.rb, line 17
def method_missing(meth, *args, &block)
  unless @mailbox.alive?
    raise DeadActorError, "attempted to call a dead actor"
  end

  if block_given?
    # FIXME: nicer exception
    raise "Cannot use blocks with futures yet"
  end

  future = Future.new
  call = SyncCall.new(future, meth, args, block)

  @mailbox << call

  future
end