Method: Concurrent::AtomicMarkableReference#update
- Defined in:
- lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb
#update {|Object| ... } ⇒ Array
Pass the current value and marked state to the given block, replacing it with the block’s results. May retry if the value changes during the block’s execution.
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb', line 105 def update loop do old_val, old_mark = reference new_val, new_mark = yield old_val, old_mark if compare_and_set old_val, new_val, old_mark, new_mark return immutable_array(new_val, new_mark) end end end |