Parent

Class/Module Index [+]

Quicksearch

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 6
def initialize(mailbox, klass)
  @mailbox, @klass = mailbox, klass
end

Public Instance Methods

inspect() click to toggle source
# File lib/celluloid/proxies/future_proxy.rb, line 10
def inspect
  "#<Celluloid::FutureProxy(#{@klass})>"
end
method_missing(meth, *args, &block) click to toggle source

method_missing black magic to call bang predicate methods asynchronously

# File lib/celluloid/proxies/future_proxy.rb, line 15
def method_missing(meth, *args, &block)
  if block_given?
    # FIXME: nicer exception
    raise "Cannot use blocks with futures yet"
  end

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

  begin
    @mailbox << call
  rescue MailboxError
    raise DeadActorError, "attempted to call a dead actor"
  end

  future
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.