@@ -18,7 +18,7 @@ module Synchronization
18
18
# Abstract object providing final, volatile, ans CAS extensions to build other concurrent abstractions.
19
19
# - final instance variables see {Object.safe_initialization!}
20
20
# - 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 }
22
22
class Object < ObjectImplementation
23
23
24
24
# @!method self.attr_volatile(*names)
@@ -87,14 +87,14 @@ def self.new(*)
87
87
# `compare_and_set_value(expected, value) #=> true || false`, `update_value(&block)`.
88
88
# @param [Array<Symbol>] names of the instance variables to be volatile with CAS.
89
89
# @return [Array<Symbol>] names of defined method names.
90
- def self . attr_volatile_with_cas ( *names )
90
+ def self . attr_atomic ( *names )
91
91
@volatile_cas_fields ||= [ ]
92
92
@volatile_cas_fields += names
93
93
safe_initialization!
94
94
define_initialize_volatile_with_cas
95
95
96
96
names . each do |name |
97
- ivar = :"@VolatileCas #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } "
97
+ ivar = :"@Atomic #{ name . to_s . gsub ( /(?:^|_)(.)/ ) { $1. upcase } } "
98
98
class_eval <<-RUBY , __FILE__ , __LINE__ + 1
99
99
def #{ name }
100
100
#{ ivar } .get
@@ -131,7 +131,7 @@ def self.volatile_cas_fields(inherited = true)
131
131
private
132
132
133
133
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 " )
135
135
class_eval <<-RUBY
136
136
def initialize_volatile_with_cas
137
137
super
0 commit comments