Method: Concurrent::AtomicFixnum#update

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

#update {|Object| ... } ⇒ Object

Pass the current value to the given block, replacing it with the block’s result. May retry if the value changes during the block’s execution.

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



135
136
137
138
139
140
141
142
# File 'lib/concurrent-ruby/concurrent/atomic/atomic_fixnum.rb', line 135

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

  alias_method :inspect, :to_s
end