Class: Celluloid::CellProxy

Inherits:
SyncProxy show all
Defined in:
lib/celluloid/proxies/cell_proxy.rb

Overview

A proxy object returned from Celluloid::Actor.new/new_link which converts the normal Ruby method protocol into an inter-actor message protocol

Instance Attribute Summary

Attributes inherited from SyncProxy

#mailbox

Instance Method Summary collapse

Methods inherited from SyncProxy

#method_missing, #respond_to?

Constructor Details

#initialize(actor_proxy, mailbox, klass) ⇒ CellProxy

Returns a new instance of CellProxy.


8
9
10
11
12
13
14
# File 'lib/celluloid/proxies/cell_proxy.rb', line 8

def initialize(actor_proxy, mailbox, klass)
  super(mailbox, klass)
  @actor_proxy  = actor_proxy
  @sync_proxy   = SyncProxy.new(mailbox, klass)
  @async_proxy  = AsyncProxy.new(mailbox, klass)
  @future_proxy = FutureProxy.new(mailbox, klass)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Celluloid::SyncProxy

Instance Method Details

#__class__Object

Used for reflecting on proxy objects themselves


6
# File 'lib/celluloid/proxies/cell_proxy.rb', line 6

def __class__; CellProxy; end

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


16
17
18
# File 'lib/celluloid/proxies/cell_proxy.rb', line 16

def _send_(meth, *args, &block)
  method_missing :__send__, meth, *args, &block
end

#alive?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/celluloid/proxies/cell_proxy.rb', line 50

def alive?
  @actor_proxy.alive?
end

#async(method_name = nil, *args, &block) ⇒ Object

Obtain an async proxy or explicitly invoke a named async method


33
34
35
36
37
38
39
# File 'lib/celluloid/proxies/cell_proxy.rb', line 33

def async(method_name = nil, *args, &block)
  if method_name
    @async_proxy.method_missing method_name, *args, &block
  else
    @async_proxy
  end
end

#future(method_name = nil, *args, &block) ⇒ Object

Obtain a future proxy or explicitly invoke a named future method


42
43
44
45
46
47
48
# File 'lib/celluloid/proxies/cell_proxy.rb', line 42

def future(method_name = nil, *args, &block)
  if method_name
    @future_proxy.method_missing method_name, *args, &block
  else
    @future_proxy
  end
end

#inspectObject


20
21
22
23
24
# File 'lib/celluloid/proxies/cell_proxy.rb', line 20

def inspect
  method_missing :inspect
rescue DeadActorError
  "#<Celluloid::CellProxy(#{@klass}) dead>"
end

#method(name) ⇒ Object


26
27
28
# File 'lib/celluloid/proxies/cell_proxy.rb', line 26

def method(name)
  Method.new(self, name)
end

#terminateObject

Terminate the associated actor


59
60
61
# File 'lib/celluloid/proxies/cell_proxy.rb', line 59

def terminate
  @actor_proxy.terminate
end

#terminate!Object

Terminate the associated actor asynchronously


64
65
66
# File 'lib/celluloid/proxies/cell_proxy.rb', line 64

def terminate!
  @actor_proxy.terminate!
end

#threadObject


54
55
56
# File 'lib/celluloid/proxies/cell_proxy.rb', line 54

def thread
  @actor_proxy.thread
end