Method: Concurrent::AtomicFixnum#compare_and_set

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

#compare_and_set(expect, update) ⇒ Boolean

Atomically sets the value to the given updated value if the current value == the expected value.

Parameters:

  • expect (Fixnum)

    the expected value

  • update (Fixnum)

    the new value

Returns:

  • (Boolean)

    true if the value was updated else false



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