Class: Celluloid::Proxy::Cell

Inherits:
Sync show all
Defined in:
lib/celluloid/proxy/cell.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 Sync

#mailbox

Instance Method Summary collapse

Methods inherited from Sync

#method_missing, #respond_to?

Constructor Details

#initialize(mailbox, actor_proxy, klass) ⇒ Cell

Returns a new instance of Cell.



9
10
11
12
13
14
15
# File 'lib/celluloid/proxy/cell.rb', line 9

def initialize(mailbox, actor_proxy, klass)
  super(mailbox, klass)
  @actor_proxy  = actor_proxy
  @sync_proxy   = ::Celluloid::Proxy::Sync.new(mailbox, klass)
  @async_proxy  = ::Celluloid::Proxy::Async.new(mailbox, klass)
  @future_proxy = ::Celluloid::Proxy::Future.new(mailbox, klass)
end

Dynamic Method Handling

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

Instance Method Details

#__class__Object

Used for reflecting on proxy objects themselves



5
6
7
# File 'lib/celluloid/proxy/cell.rb', line 5

def __class__
  ::Celluloid::Proxy::Cell
end

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



17
18
19
# File 'lib/celluloid/proxy/cell.rb', line 17

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

#alive?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/celluloid/proxy/cell.rb', line 51

def alive?
  @actor_proxy.alive?
end

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

Obtain an async proxy or explicitly invoke a named async method



34
35
36
37
38
39
40
# File 'lib/celluloid/proxy/cell.rb', line 34

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

#dead?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/celluloid/proxy/cell.rb', line 55

def dead?
  @actor_proxy.dead?
end

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

Obtain a future proxy or explicitly invoke a named future method



43
44
45
46
47
48
49
# File 'lib/celluloid/proxy/cell.rb', line 43

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

#inspectObject



21
22
23
24
25
# File 'lib/celluloid/proxy/cell.rb', line 21

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

#method(name) ⇒ Object



27
28
29
# File 'lib/celluloid/proxy/cell.rb', line 27

def method(name)
  ::Celluloid::Internals::Method.new(self, name)
end

#terminateObject

Terminate the associated actor



64
65
66
# File 'lib/celluloid/proxy/cell.rb', line 64

def terminate
  @actor_proxy.terminate
end

#terminate!Object

Terminate the associated actor asynchronously



69
70
71
# File 'lib/celluloid/proxy/cell.rb', line 69

def terminate!
  @actor_proxy.terminate!
end

#threadObject



59
60
61
# File 'lib/celluloid/proxy/cell.rb', line 59

def thread
  @actor_proxy.thread
end