Class: Celluloid::Proxy::Cell
- Inherits:
-
Sync
- Object
- Abstract
- AbstractCall
- Sync
- Celluloid::Proxy::Cell
- 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 AbstractCall
Instance Method Summary collapse
- #_send_(meth, *args, &block) ⇒ Object
- #alive? ⇒ Boolean
-
#async(method_name = nil, *args, &block) ⇒ Object
Obtain an async proxy or explicitly invoke a named async method.
- #dead? ⇒ Boolean
-
#future(method_name = nil, *args, &block) ⇒ Object
Obtain a future proxy or explicitly invoke a named future method.
-
#initialize(mailbox, actor_proxy, klass) ⇒ Cell
constructor
A new instance of Cell.
- #inspect ⇒ Object
- #method(name) ⇒ Object
-
#terminate ⇒ Object
Terminate the associated actor.
-
#terminate! ⇒ Object
Terminate the associated actor asynchronously.
- #thread ⇒ Object
Methods inherited from Sync
Methods inherited from AbstractCall
Methods inherited from Abstract
Constructor Details
#initialize(mailbox, actor_proxy, klass) ⇒ Cell
Returns a new instance of Cell.
4 5 6 7 8 9 |
# File 'lib/celluloid/proxy/cell.rb', line 4 def initialize(mailbox, actor_proxy, klass) super(mailbox, klass) @actor_proxy = actor_proxy @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
#_send_(meth, *args, &block) ⇒ Object
11 12 13 |
# File 'lib/celluloid/proxy/cell.rb', line 11 def _send_(meth, *args, &block) method_missing :__send__, meth, *args, &block end |
#alive? ⇒ Boolean
45 46 47 |
# File 'lib/celluloid/proxy/cell.rb', line 45 def alive? @actor_proxy.alive? end |
#async(method_name = nil, *args, &block) ⇒ Object
Obtain an async proxy or explicitly invoke a named async method
28 29 30 31 32 33 34 |
# File 'lib/celluloid/proxy/cell.rb', line 28 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
49 50 51 |
# File 'lib/celluloid/proxy/cell.rb', line 49 def dead? @actor_proxy.dead? end |
#future(method_name = nil, *args, &block) ⇒ Object
Obtain a future proxy or explicitly invoke a named future method
37 38 39 40 41 42 43 |
# File 'lib/celluloid/proxy/cell.rb', line 37 def future(method_name = nil, *args, &block) if method_name @future_proxy.method_missing method_name, *args, &block else @future_proxy end end |
#inspect ⇒ Object
15 16 17 18 19 |
# File 'lib/celluloid/proxy/cell.rb', line 15 def inspect method_missing :inspect rescue ::Celluloid::DeadActorError "#<::Celluloid::Proxy::Cell(#{@klass}) dead>" end |
#method(name) ⇒ Object
21 22 23 |
# File 'lib/celluloid/proxy/cell.rb', line 21 def method(name) ::Celluloid::Internals::Method.new(self, name) end |
#terminate ⇒ Object
Terminate the associated actor
58 59 60 |
# File 'lib/celluloid/proxy/cell.rb', line 58 def terminate @actor_proxy.terminate end |
#terminate! ⇒ Object
Terminate the associated actor asynchronously
63 64 65 |
# File 'lib/celluloid/proxy/cell.rb', line 63 def terminate! @actor_proxy.terminate! end |
#thread ⇒ Object
53 54 55 |
# File 'lib/celluloid/proxy/cell.rb', line 53 def thread @actor_proxy.thread end |