Class: Concurrent::ErlangActor::Pid
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Concurrent::Synchronization::Object
|
Defined in: | lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb |
Overview
The public reference of the actor which can be stored and passed around. Nothing else of the actor should be exposed. Functions#spawn_actor and Environment#spawn return the pid.
Class Attribute Summary
Synchronization::Object
- Inherited
Class Method Summary
- .new(actor, name) ⇒ Pid constructor private
Synchronization::Object
- Inherited
.atomic_attribute?, .atomic_attributes, | |
.attr_atomic | Creates methods for reading and writing to a instance variable with volatile (Java) semantic as |
.attr_volatile | Creates methods for reading and writing (as |
.ensure_safe_initialization_when_final_fields_are_present | For testing purposes, quite slow. |
.new | Has to be called by children. |
.safe_initialization!, .define_initialize_atomic_fields |
Synchronization::AbstractObject
- Inherited
Instance Method Summary
-
#ask(message, timeout = nil, timeout_value = nil) ⇒ Object, timeout_value
The actor is asked the message and blocks until a reply is available, which is returned by the method.
-
#ask_op(message, probe = Promises.resolvable_future) ⇒ Promises::Future(Object)
Same as #tell but represented as a
Promises::Future
. -
#inspect
Alias for #to_s.
- #name ⇒ #to_s?
-
#tell(message, timeout = nil) ⇒ self, ...
The actor is asynchronously told a message.
-
#tell_op(message) ⇒ Promises::Future(self)
Same as #tell but represented as a
Promises::Future
. - #terminated ⇒ Promises::Future
- #to_s ⇒ String (also: #inspect)
Synchronization::Object
- Inherited
Synchronization::Volatile
- Included
Synchronization::AbstractObject
- Inherited
Constructor Details
.new(actor, name) ⇒ Pid
(private)
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 129
def initialize(actor, name) @Actor = actor @Name = name end
Instance Method Details
#ask(message, timeout = nil, timeout_value = nil) ⇒ Object, timeout_value
The actor is asked the message and blocks until a reply is available, which is returned by the method. If the reply is a rejection then the methods raises it.
If the actor does not call Environment#reply or Environment#reply_resolution the method will raise NoReply
error. If the actor is terminated it will raise NoActor
. Therefore the ask is never left unanswered and blocking.
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 81
def ask(, timeout = nil, timeout_value = nil) @Actor.ask , timeout, timeout_value end
#ask_op(message, probe = Promises.resolvable_future) ⇒ Promises::Future(Object)
Same as #tell but represented as a Promises::Future
.
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 90
def ask_op(, probe = Promises.resolvable_future) @Actor.ask_op , probe end
#inspect
Alias for #to_s.
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 123
alias_method :inspect, :to_s
#name ⇒ #to_s?
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 103
def name @Name end
#tell(message, timeout = nil) ⇒ self
, ...
The actor is asynchronously told a message. The method returns immediately unless the actor has bounded mailbox and there is no more space for the message. Then the method blocks current thread until there is space available. This is useful for backpressure.
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 56
def tell(, timeout = nil) @Actor.tell , timeout end
#tell_op(message) ⇒ Promises::Future(self
)
Same as #tell but represented as a Promises::Future
.
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 63
def tell_op( ) @Actor.tell_op( ) end
#terminated ⇒ Promises::Future
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 98
def terminated @Actor.terminated end
#to_s ⇒ String
Also known as: #inspect
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 108
def to_s original = super state = case terminated.state when :pending 'running' when :fulfilled "terminated normally with #{terminated.value}" when :rejected "terminated because of #{terminated.reason}" else raise end [original[0..-2], *@Name, state].join(' ') << '>' end