Module: Concurrent::AtomicDirectUpdate
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb |
Overview
Note:
**Private Implementation:** This abstraction is a private, internal implementation detail. It should never be used directly.
Define update methods that use direct paths
Instance Method Summary
Instance Method Details
#try_update
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb', line 15
def try_update old_value = get new_value = yield old_value return unless compare_and_set old_value, new_value new_value end
#try_update!
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb', line 24
def try_update! old_value = get new_value = yield old_value unless compare_and_set(old_value, new_value) if $VERBOSE raise ConcurrentUpdateError, "Update failed" else raise ConcurrentUpdateError, "Update failed", ConcurrentUpdateError::CONC_UP_ERR_BACKTRACE end end new_value end
#update
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb', line 10
def update true until compare_and_set(old_value = get, new_value = yield(old_value)) new_value end