lib/garcon/task/atomic.rb
# Pass the current value to the given block, replacing it with the block's
# result. Raise an exception if the update fails.
#
# @yield [Object]
#   Calculate a new value for the atomic reference using given (old) value.
# @yieldparam [Object] old_value
#   The starting value of the atomic reference.
#
# @raise [Garcon::ConcurrentUpdateError]
#   If the update fails
#
# @return [Object] the new value
Pass the current value to the given block, replacing it with the block's
result. Raise an exception if the update fails.
Pass the current value to the given block replacing it with the block ' s result . Raise an exception if the update fails .
def try_update
      old_value = get
      new_value = yield old_value
      unless compare_and_set(old_value, new_value)
        raise ConcurrentUpdateError, "Update failed"
      end
      new_value
    end
def try_update old_value = get new_value = yield old_value unless compare_and_set ( old_value , new_value ) raise ConcurrentUpdateError , "Update failed" end new_value end
Pass the current value to the given block, replacing it with the block's
result.
Pass the current value to the given block replacing it with the block ' s result .
the new value
the new value
Object
[Garcon::ConcurrentUpdateError] If the update fails
[ Garcon :: ConcurrentUpdateError ] If the update fails
]
<not_specific>
Calculate a new value for the atomic reference using given (old) value.
Calculate a new value for the atomic reference using given ( old ) value .
<not_specific>
old_value The starting value of the atomic reference.
old_value The starting value of the atomic reference .