Class: Concurrent::Futures::Ref
- Inherits:
-
Object
- Object
- Concurrent::Futures::Ref
- Defined in:
- lib/concurrent/futures.rb
Instance Method Summary collapse
- #exchange(value) ⇒ Object
-
#initialize(value = nil) ⇒ Ref
constructor
A new instance of Ref.
- #modify(&block) ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ Ref
Returns a new instance of Ref.
126 127 128 129 |
# File 'lib/concurrent/futures.rb', line 126 def initialize( value=nil ) @lock = Mutex.new @value = value end |
Instance Method Details
#exchange(value) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/concurrent/futures.rb', line 131 def exchange( value ) @lock.synchronize do result = @value @value = value result end end |