Class: Concurrent::ThreadSafe::Util::Striped64::Cell
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
AtomicReference
|
|
Instance Chain:
self,
AtomicReference
|
|
Inherits: |
Concurrent::AtomicReference
|
Defined in: | lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb |
Overview
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.
Class Method Summary
Instance Method Summary
AtomicReference
- Inherited
#compare_and_set | Atomically sets the value to the given updated value if the current value == the expected value. |
#get | Gets the current value. |
#get_and_set | Atomically sets to the given value and returns the old value. |
#inspect | Alias for AtomicReference#to_s. |
#set | Sets to the given value. |
#to_s, | |
#try_update | Pass the current value to the given block, replacing it with the block’s result. |
#try_update! | Pass the current value to the given block, replacing it with the block’s result. |
#update | Pass the current value to the given block, replacing it with the block’s result. |
Constructor Details
This class inherits a constructor from Concurrent::AtomicReference
Class Method Details
.padding (private)
[ GitHub ]# 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
Instance Method Details
#cas(old_value, new_value)
Alias for AtomicReference#compare_and_set.
# File 'lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb', line 89
alias_method :cas, :compare_and_set
#cas_computed
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb', line 91
def cas_computed cas(current_value = value, yield(current_value)) end