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
-
#__class__ ⇒ Object
Used for reflecting on proxy objects themselves.
- #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.
Constructor Details
#initialize(mailbox, thread) ⇒ Actor
Returns a new instance of Actor.
10 11 12 13 |
# File 'lib/celluloid/proxy/actor.rb', line 10 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
#__class__ ⇒ Object
Used for reflecting on proxy objects themselves
6 7 8 |
# File 'lib/celluloid/proxy/actor.rb', line 6 def __class__ ::Celluloid::Proxy::Actor end |
#alive? ⇒ Boolean
22 23 24 |
# File 'lib/celluloid/proxy/actor.rb', line 22 def alive? @mailbox.alive? end |
#dead? ⇒ Boolean
26 27 28 |
# File 'lib/celluloid/proxy/actor.rb', line 26 def dead? !alive? end |
#inspect ⇒ Object
15 16 17 18 19 20 |
# File 'lib/celluloid/proxy/actor.rb', line 15 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
31 32 33 34 35 |
# File 'lib/celluloid/proxy/actor.rb', line 31 def terminate terminate! ::Celluloid::Actor.join(self) nil end |
#terminate! ⇒ Object
Terminate the associated actor asynchronously
38 39 40 41 |
# File 'lib/celluloid/proxy/actor.rb', line 38 def terminate! ::Kernel.raise ::Celluloid::DeadActorError, "actor already terminated" unless alive? @mailbox << ::Celluloid::TerminationRequest.new end |