Class: Concurrent::ErlangActor::Pid
- Inherits:
-
Synchronization::Object
- Object
- Synchronization::Object
- Concurrent::ErlangActor::Pid
- Defined in:
- lib-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.
Instance Method Summary collapse
-
#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.
-
#name ⇒ #to_s, nil
Optional name of the actor.
-
#tell(message, timeout = nil) ⇒ self, true, false
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
A future which is resolved with the final result of the actor that is either the reason for termination or a value if terminated normally.
-
#to_s ⇒ String
(also: #inspect)
String representation.
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.
77 78 79 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 77 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.
86 87 88 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 86 def ask_op(, probe = Promises.resolvable_future) @Actor.ask_op , probe end |
#name ⇒ #to_s, nil
Returns optional name of the actor
99 100 101 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 99 def name @Name end |
#tell(message, timeout = nil) ⇒ self, true, false
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.
52 53 54 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 52 def tell(, timeout = nil) @Actor.tell , timeout end |
#tell_op(message) ⇒ Promises::Future(self)
Same as #tell but represented as a Promises::Future.
59 60 61 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 59 def tell_op() @Actor.tell_op() end |
#terminated ⇒ Promises::Future
Returns a future which is resolved with the final result of the actor that is either the reason for termination or a value if terminated normally.
94 95 96 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 94 def terminated @Actor.terminated end |
#to_s ⇒ String Also known as: inspect
Returns string representation
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib-edge/concurrent/edge/erlang_actor.rb', line 104 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 |