Class: Concurrent::Actress::Reference
- Inherits:
-
Object
- Object
- Concurrent::Actress::Reference
- Includes:
- CoreDelegations, TypeCheck
- Defined in:
- lib/concurrent/actress/reference.rb
Overview
Reference is public interface of Actor instances. It is used for sending messages and can be freely passed around the program. It also provides some basic information about the actor see CoreDelegations
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#ask(message, ivar = IVar.new) ⇒ IVar
tells message to the actor.
-
#ask!(message, ivar = IVar.new) ⇒ Object
tells message to the actor.
-
#message(message, ivar = nil) ⇒ Object
behaves as #tell when no ivar and as #ask when ivar.
-
#tell(message) ⇒ Reference
(also: #<<)
tells message to the actor.
- #to_s ⇒ Object (also: #inspect)
Methods included from CoreDelegations
#executor, #name, #parent, #path, #reference, #terminated, #terminated?
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Instance Method Details
#==(other) ⇒ Object
58 59 60 |
# File 'lib/concurrent/actress/reference.rb', line 58 def ==(other) Type? other, self.class and other.send(:core) == core end |
#ask(message, ivar = IVar.new) ⇒ IVar
tells message to the actor
32 33 34 |
# File 'lib/concurrent/actress/reference.rb', line 32 def ask(, ivar = IVar.new) , ivar end |
#ask!(message, ivar = IVar.new) ⇒ Object
Note:
can lead to deadlocks, use only in tests or when you are sure it won’t deadlock
tells message to the actor
42 43 44 |
# File 'lib/concurrent/actress/reference.rb', line 42 def ask!(, ivar = IVar.new) ask(, ivar).value! end |
#message(message, ivar = nil) ⇒ Object
behaves as #tell when no ivar and as #ask when ivar
47 48 49 50 |
# File 'lib/concurrent/actress/reference.rb', line 47 def (, ivar = nil) core.on_envelope Envelope.new(, ivar, Actress.current || Thread.current) return ivar || self end |
#tell(message) ⇒ Reference Also known as: <<
tells message to the actor
22 23 24 |
# File 'lib/concurrent/actress/reference.rb', line 22 def tell() , nil end |
#to_s ⇒ Object Also known as: inspect
52 53 54 |
# File 'lib/concurrent/actress/reference.rb', line 52 def to_s "#<#{self.class} #{path}>" end |