Module: Concurrent::AtomicNumericCompareAndSetWrapper
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb |
Overview
Note:
**Private Implementation:** This abstraction is a private, internal implementation detail. It should never be used directly.
Special “compare and set” handling of numeric values.
Instance Method Summary
-
#compare_and_set(old_value, new_value) ⇒ Boolean
Atomically sets the value to the given updated value if the current value == the expected value.
Instance Method Details
#compare_and_set(old_value, new_value) ⇒ Boolean
Atomically sets the value to the given updated value if the current value == the expected value.
that the actual value was not equal to the expected value.
# File 'lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb', line 10
def compare_and_set(old_value, new_value) if old_value.kind_of? Numeric while true old = get return false unless old.kind_of? Numeric return false unless old == old_value result = _compare_and_set(old, new_value) return result if result end else _compare_and_set(old_value, new_value) end end