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.
128 129 130 131 |
# File 'lib/concurrent/futures.rb', line 128 def initialize( value=nil ) @lock = Mutex.new @value = value end |
Instance Method Details
#exchange(value) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/concurrent/futures.rb', line 133 def exchange( value ) @lock.synchronize do result = @value @value = value result end end |