Parent

Class/Module Index [+]

Quicksearch

Celluloid::AsyncProxy

A proxy which sends asynchronous calls to an actor

Attributes

mailbox[R]

Public Class Methods

new(mailbox, klass) click to toggle source
# File lib/celluloid/proxies/async_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/async_proxy.rb, line 10
def inspect
  "#<Celluloid::AsyncProxy(#{@klass})>"
end
method_missing(meth, *args, &block) click to toggle source
# File lib/celluloid/proxies/async_proxy.rb, line 14
def method_missing(meth, *args, &block)
  if @mailbox == ::Thread.current[:celluloid_mailbox]
    args.unshift meth
    meth = :__send__
  end

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

  begin
    @mailbox << AsyncCall.new(meth, args, block)
  rescue MailboxError
    # Silently swallow asynchronous calls to dead actors. There's no way
    # to reliably generate DeadActorErrors for async calls, so users of
    # async calls should find other ways to deal with actors dying
    # during an async call (i.e. linking/supervisors)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.