Class: Celluloid::Proxy::Actor
- Defined in:
- lib/celluloid/proxy/actor.rb
Overview
A proxy which controls the Actor lifecycle
Instance Attribute Summary collapse
-
#mailbox ⇒ Object
readonly
Returns the value of attribute mailbox.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #dead? ⇒ Boolean
-
#initialize(mailbox, thread) ⇒ Actor
constructor
A new instance of Actor.
- #inspect ⇒ Object
-
#terminate ⇒ Object
Terminate the associated actor.
-
#terminate! ⇒ Object
Terminate the associated actor asynchronously.
Methods inherited from Abstract
Constructor Details
#initialize(mailbox, thread) ⇒ Actor
Returns a new instance of Actor.
5 6 7 8 |
# File 'lib/celluloid/proxy/actor.rb', line 5 def initialize(mailbox, thread) @mailbox = mailbox @thread = thread end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
3 4 5 |
# File 'lib/celluloid/proxy/actor.rb', line 3 def mailbox @mailbox end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
3 4 5 |
# File 'lib/celluloid/proxy/actor.rb', line 3 def thread @thread end |
Instance Method Details
#alive? ⇒ Boolean
17 18 19 |
# File 'lib/celluloid/proxy/actor.rb', line 17 def alive? @mailbox.alive? end |
#dead? ⇒ Boolean
21 22 23 |
# File 'lib/celluloid/proxy/actor.rb', line 21 def dead? !alive? end |
#inspect ⇒ Object
10 11 12 13 14 15 |
# File 'lib/celluloid/proxy/actor.rb', line 10 def inspect # TODO: use a system event to fetch actor state: tasks? "#<Celluloid::Proxy::Actor(#{@mailbox.address}) alive>" rescue DeadActorError "#<Celluloid::Proxy::Actor(#{@mailbox.address}) dead>" end |
#terminate ⇒ Object
Terminate the associated actor
26 27 28 29 30 |
# File 'lib/celluloid/proxy/actor.rb', line 26 def terminate terminate! ::Celluloid::Actor.join(self) nil end |
#terminate! ⇒ Object
Terminate the associated actor asynchronously
33 34 35 36 |
# File 'lib/celluloid/proxy/actor.rb', line 33 def terminate! ::Kernel.raise ::Celluloid::DeadActorError, "actor already terminated" unless alive? @mailbox << ::Celluloid::TerminationRequest.new end |