You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**serialized (S)** - Operations are serialized in some order (they
58
65
cannot disappear). This is a new property not mentioned in other memory
59
66
models, since Java and C++ do not have dynamically defined fields. All
60
-
operations on one line in the table are serialized with each other.
67
+
operations on one line in a row of the tables bellow are serialized with
68
+
each other.
61
69
62
70
### Core behavior:
63
71
64
72
| Operation | V | A | S | Notes |
65
73
|:----------|:-:|:-:|:-:|:-----|
66
-
| local variable read/write/definition | - | x | x | Local variables are determined during parsing, they are not usually dinamically added (with exception of `local_variable_set`). Therefore definition is quite rare. |
67
-
| instance variable read/write/(un)definition | - | x | x ||
74
+
| local variable read/write/definition | - | x | x | Local variables are determined during parsing, they are not usually dynamically added (with exception of `local_variable_set`). Therefore definition is quite rare. |
75
+
| instance variable read/write/(un)definition | - | x | x | Newly defined instance variables have to become visible eventually. |
68
76
| class variable read/write/(un)definition | x | x | x ||
69
77
| global variable read/write/definition | x | x | x | un-define us not possible currently. |
70
78
| constant variable read/write/(un)definition | x | x | x ||
71
-
|`Thread` local variable read/write/definition | - | x | x | un-define us not possible currently. |
72
-
|`Fiber` local variable read/write/definition | - | x | x | un-define us not possible currently. |
79
+
|`Thread` local variable read/write/definition | - | x | x | un-define is not possible currently. |
80
+
|`Fiber` local variable read/write/definition | - | x | x | un-define is not possible currently. |
73
81
| method creation/redefinition/removal | x | x | x ||
74
82
| include/extend | x | x | x | If `AClass` is included `AModule`, `AClass` gets all `AModule`'s methods at once. |
75
83
@@ -87,14 +95,16 @@ Notes:
87
95
- Method invocation does not have any special properties that includes
88
96
object initialization.
89
97
90
-
Implementation differences from the model:
98
+
Current Implementation differences from the model:
91
99
92
100
- MRI: everything is volatile.
93
101
- JRuby: `Thread` and `Fiber` local variables are volatile. Instance
94
102
variables are volatile on x86 and people may un/intentionally depend
95
103
on the fact.
96
104
- Class variables require investigation.
97
105
106
+
> TODO: updated with specific versions of the implementations.
107
+
98
108
### Source loading:
99
109
100
110
| Operation | V | A | S | Notes |
@@ -106,7 +116,7 @@ Notes:
106
116
107
117
- Beware of requiring and autoloading in concurrent programs, it's possible to
108
118
see partially defined classes. Eager loading or blocking until class is
109
-
fully loaded has should be used to mitigate.
119
+
fully loaded should be used to mitigate.
110
120
111
121
### Core classes
112
122
@@ -188,7 +198,7 @@ library cannot alter meaning of `@a_name` expression therefore when a
188
198
`a_name` to be volatile, it creates method accessors.
189
199
190
200
> However there is Ruby [issue](https://redmine.ruby-lang.org/issues/11539)
191
-
> filled to address this.
201
+
> filed to address this.
192
202
193
203
``` ruby
194
204
# Simple counter with cheap reads.
@@ -215,10 +225,10 @@ class Counter < Concurrent::Synchronization::Object
215
225
value
216
226
end
217
227
218
-
# Safely increment the value without loosing updates
228
+
# Safely increments the value without loosing updates
219
229
# (as it would happen with just += used).
220
230
defincrement(add)
221
-
# Wrap he two volatile operations to make them atomic.
231
+
# Wrap the two volatile operations to make them atomic.
222
232
@Lock.synchronize do
223
233
# volatile write and read
224
234
self.value =self.value + add
@@ -229,7 +239,7 @@ end
229
239
230
240
> This is currently planned to be migrated to a module to be able to add
231
241
> volatile fields any object not just `Synchronization::Object` children. The
232
-
> instance variable itself is named `@"volatile_#(name)"` to distinguish it and
242
+
> instance variable itself is named `"@volatile_#{name}"` to distinguish it and
233
243
> to prevent direct access by name.
234
244
235
245
## Volatile instance variable with compare-and-set
@@ -298,59 +308,6 @@ Three of them were used in the example above.
298
308
> Current implementation relies on final instance variables where a instance of
299
309
> `AtomicReference` is held to provide compare-and-set operations. That creates
300
310
> extra indirection which is hoped to be removed over time when better
301
-
> implementation will become available in Ruby implementations.
302
-
303
-
## Concurrent Ruby Notes
304
-
305
-
### Locks
306
-
307
-
Concurrent Ruby also has an internal extension of `Object` called
308
-
`LockableObject`, which provides same synchronization primitives as Java's
0 commit comments