lib/celluloid/proxies/future_proxy.rb in celluloid-0.14.1 vs lib/celluloid/proxies/future_proxy.rb in celluloid-0.15.0.pre

- old
+ new

@@ -1,32 +1,34 @@ module Celluloid # A proxy which creates future calls to an actor class FutureProxy < AbstractProxy attr_reader :mailbox + # Used for reflecting on proxy objects themselves + def __class__; FutureProxy; end + def initialize(mailbox, klass) @mailbox, @klass = mailbox, klass end def inspect "#<Celluloid::FutureProxy(#{@klass})>" end - # method_missing black magic to call bang predicate methods asynchronously 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) - begin - @mailbox << call - rescue MailboxError - raise DeadActorError, "attempted to call a dead actor" - end + @mailbox << call future end end end