Method: Concurrent::AtomicReference#try_update!

Defined in:
lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb

#try_update! {|Object| ... } ⇒ Object

Note:

This behavior mimics the behavior of the original ‘AtomicReference#try_update` API. The reason this was changed was to avoid raising exceptions (which are inherently slow) by default. For more info: github.com/ruby-concurrency/concurrent-ruby/pull/336

Pass the current value to the given block, replacing it with the block’s result. Raise an exception if the update fails.

Yields:

  • (Object)

    Calculate a new value for the atomic reference using given (old) value

Yield Parameters:

  • old_value (Object)

    the starting value of the atomic reference

Returns:

  • (Object)

    the new value

Raises:



126
127
128
129
130
131
132
133
134
# File 'lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb', line 126

class AtomicReference < AtomicReferenceImplementation

  # @return [String] Short string representation.
  def to_s
    format '%s value:%s>', super[0..-2], get
  end

  alias_method :inspect, :to_s
end