module Concurrent::AtomicDirectUpdate
def try_update
-
(Object)- the new value, or nil if update failed
Other tags:
- Note: - This method was altered to avoid raising an exception by default.
Other tags:
- Yieldparam: old_value - the starting value of the atomic reference
Other tags:
- Yield: - Calculate a new value for the atomic reference using
def try_update old_value = get new_value = yield old_value return unless compare_and_set old_value, new_value new_value end
def try_update!
-
(Concurrent::ConcurrentUpdateError)- if the update fails
Returns:
-
(Object)- the new value
Other tags:
- Note: - This behavior mimics the behavior of the original
Other tags:
- Yieldparam: old_value - the starting value of the atomic reference
Other tags:
- Yield: - Calculate a new value for the atomic reference using
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
def update
-
(Object)- the new value
Other tags:
- Yieldparam: old_value - the starting value of the atomic reference
Other tags:
- Yield: - Calculate a new value for the atomic reference using
def update true until compare_and_set(old_value = get, new_value = yield(old_value)) new_value end