Class: Concurrent::Actor::Reference
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
PublicDelegations ,
TypeCheck
|
|
Inherits: | Object |
Defined in: | lib/concurrent-ruby-edge/concurrent/actor/reference.rb |
Overview
Reference
is public interface of Actor
instances. It is used for sending messages and can be freely passed around the application. It also provides some basic information about the actor, see PublicDelegations
.
AdHoc.spawn('printer') { -> { puts } }
# => #<Concurrent::Actor::Reference:0x7fd0d2883218 /printer (Concurrent::Actor::Utils::AdHoc)>
# ^object_id ^path ^context class
Class Method Summary
- .new(core) ⇒ Reference constructor private
Instance Attribute Summary
- #core readonly private
Instance Method Summary
-
#<<(message)
Alias for #tell.
- #==(other)
- #ask(message, future = Concurrent::Promises.resolvable_future) ⇒ Promises::Future (also: #ask_op)
-
#ask!(message, future = Concurrent::Promises.resolvable_future) ⇒ Object
Sends the message synchronously and blocks until the message is processed.
-
#ask_op(message, future = Concurrent::Promises.resolvable_future)
Alias for #ask.
- #dead_letter_routing
-
#inspect
Alias for #to_s.
- #map(messages)
- #message(message, future = nil)
-
#tell(message) ⇒ Reference
(also: #<<)
Sends the message asynchronously to the actor and immediately returns
self
(the reference) allowing to chain message telling. - #to_s (also: #inspect)
PublicDelegations
- Included
#actor_class | Alias for PublicDelegations#context_class. |
#context_class, #executor, #name, #parent, #path, | |
#ref | Alias for PublicDelegations#reference. |
#reference |
TypeCheck
- Included
Constructor Details
.new(core) ⇒ Reference
(private)
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 22
def initialize(core) @core = Type! core, Core end
Instance Attribute Details
#core (readonly, private)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 18
attr_reader :core
Instance Method Details
#<<(message)
Alias for #tell.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 39
alias_method :<<, :tell
#==(other)
[ GitHub ]#ask(message, future = Concurrent::Promises.resolvable_future) ⇒ Promises::Future Also known as: #ask_op
it’s a good practice to use #tell whenever possible. Results can be sent back with other messages. Ask should be used only for testing and when it returns very shortly. It can lead to deadlock if all threads in global_io_executor will block on while asking. It’s fine to use it form outside of actors and global_io_executor.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 52
def ask(, future = Concurrent::Promises.resolvable_future) , future end
#ask!(message, future = Concurrent::Promises.resolvable_future) ⇒ Object
it’s a good practice to use #tell whenever possible. Results can be sent back with other messages. Ask should be used only for testing and when it returns very shortly. It can lead to deadlock if all threads in global_io_executor will block on while asking. It’s fine to use it form outside of actors and global_io_executor.
Sends the message synchronously and blocks until the message is processed. Raises on error.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 73
def ask!(, future = Concurrent::Promises.resolvable_future) ask(, future).value! end
#ask_op(message, future = Concurrent::Promises.resolvable_future)
Alias for #ask.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 57
alias_method :ask_op, :ask
#dead_letter_routing
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 88
def dead_letter_routing core.dead_letter_routing end
#inspect
Alias for #to_s.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 96
alias_method :inspect, :to_s
#map(messages)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 77
def map( ) .map { |m| self.ask(m) } end
#message(message, future = nil)
[ GitHub ]
#tell(message) ⇒ Reference
Also known as: #<<
Sends the message asynchronously to the actor and immediately returns self
(the reference) allowing to chain message telling.
# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 35
def tell( ) , nil end
#to_s Also known as: #inspect
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/actor/reference.rb', line 92
def to_s format '%s %s (%s)>', super[0..-2], path, actor_class end