Class: Celluloid::Proxy::Future

Inherits:
AbstractCall show all
Defined in:
lib/celluloid/proxy/future.rb

Overview

A proxy which creates future calls to an actor

Instance Attribute Summary

Attributes inherited from AbstractCall

#mailbox

Instance Method Summary collapse

Methods inherited from AbstractCall

#__klass__, #eql?, #hash, #initialize, #inspect

Methods inherited from Abstract

#__class__

Constructor Details

This class inherits a constructor from Celluloid::Proxy::AbstractCall

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/celluloid/proxy/future.rb', line 3

def method_missing(meth, *args, &block)
  raise ::Celluloid::DeadActorError, "attempted to call a dead actor: #{meth}" unless @mailbox.alive?

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

  future = ::Celluloid::Future.new
  call = ::Celluloid::Call::Sync.new(future, meth, args, block)

  @mailbox << call

  future
end