@@ -18,7 +18,7 @@ module Synchronization
1818 # Abstract object providing final, volatile, ans CAS extensions to build other concurrent abstractions.
1919 # - final instance variables see {Object.safe_initialization!}
2020 # - volatile instance variables see {Object.attr_volatile}
21- # - volatile instance variables see {Object.attr_volatile_with_cas }
21+ # - volatile instance variables see {Object.attr_atomic }
2222 class Object < ObjectImplementation
2323
2424 # @!method self.attr_volatile(*names)
@@ -87,14 +87,14 @@ def self.new(*)
8787 # `compare_and_set_value(expected, value) #=> true || false`, `update_value(&block)`.
8888 # @param [Array<Symbol>] names of the instance variables to be volatile with CAS.
8989 # @return [Array<Symbol>] names of defined method names.
90- def self . attr_volatile_with_cas ( *names )
90+ def self . attr_atomic ( *names )
9191 @volatile_cas_fields ||= [ ]
9292 @volatile_cas_fields += names
9393 safe_initialization!
9494 define_initialize_volatile_with_cas
9595
9696 names . each do |name |
97- ivar = :"@VolatileCas #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } "
97+ ivar = :"@Atomic #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } "
9898 class_eval <<-RUBY , __FILE__ , __LINE__ + 1
9999 def #{ name }
100100 #{ ivar } .get
@@ -131,7 +131,7 @@ def self.volatile_cas_fields(inherited = true)
131131 private
132132
133133 def self . define_initialize_volatile_with_cas
134- assignments = @volatile_cas_fields . map { |name | "@VolatileCas #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } = AtomicReference.new(nil)" } . join ( "\n " )
134+ assignments = @volatile_cas_fields . map { |name | "@Atomic #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } = AtomicReference.new(nil)" } . join ( "\n " )
135135 class_eval <<-RUBY
136136 def initialize_volatile_with_cas
137137 super
0 commit comments