class Concurrent::ThreadSafe::Util::Striped64::Cell

Padded variant of AtomicLong supporting only raw accesses plus CAS. The value field is placed between pads, hoping that the JVM doesn’t reorder them.

Optimisation note: It would be possible to use a release-only form of CAS here, if it were provided.

@!visibility private

Public Class Methods

padding() click to toggle source

@!visibility private

# File lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb, line 96
def self.padding
  # TODO: this only adds padding after the :value slot, need to find a way to add padding before the slot
  # TODO (pitr-ch 28-Jul-2018): the padding instance vars may not be created
  # hide from yardoc in a method
  attr_reader :padding_0, :padding_1, :padding_2, :padding_3, :padding_4, :padding_5, :padding_6, :padding_7, :padding_8, :padding_9, :padding_10, :padding_11
end

Public Instance Methods

cas_computed() { |current_value| ... } click to toggle source
# File lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb, line 91
def cas_computed
  cas(current_value = value, yield(current_value))
end