Class: Celluloid::FutureProxy

Inherits:
AbstractProxy show all
Defined in:
lib/celluloid/proxies/future_proxy.rb

Overview

A proxy which creates future calls to an actor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mailbox, klass) ⇒ FutureProxy


9
10
11
# File 'lib/celluloid/proxies/future_proxy.rb', line 9

def initialize(mailbox, klass)
  @mailbox, @klass = mailbox, klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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

Instance Attribute Details

#mailboxObject (readonly)

Returns the value of attribute mailbox


4
5
6
# File 'lib/celluloid/proxies/future_proxy.rb', line 4

def mailbox
  @mailbox
end

Instance Method Details

#__class__Object

Used for reflecting on proxy objects themselves


7
# File 'lib/celluloid/proxies/future_proxy.rb', line 7

def __class__; FutureProxy; end

#inspectObject


13
14
15
# File 'lib/celluloid/proxies/future_proxy.rb', line 13

def inspect
  "#<Celluloid::FutureProxy(#{@klass})>"
end