File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,13 @@ class Node
52
52
# ...
53
53
end
54
54
```
55
+ ## Piggybacking
56
+
57
+ Any write executed before volatile write based on program-order is visible to
58
+ the volatile read as well, which allows
59
+ [ piggybacking] ( http://stackoverflow.com/questions/8769570/volatile-piggyback-is-this-enough-for-visiblity ) .
60
+ Because it creates synchronizes-with (JMM term) order between volatile write
61
+ and read, which participates in creating happens-before order.
62
+
63
+ This trick is used in some of the abstractions, to avoid unnecessary
64
+ synchronization or volatile declarations.
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ time-consuming and error-prone.
34
34
The Ruby memory model is a framework allowing to reason about programs in
35
35
concurrent and parallel environment. It defines what variable writes can be
36
36
observed by a particular variable read, which is essential to be able to
37
- determine if a program is correct. It is achieved be defining what subset of
37
+ determine if a program is correct. It is achieved by defining what subset of
38
38
all possible program execution orders is allowed.
39
39
40
40
A memory model sources:
@@ -70,14 +70,9 @@ C++11). This is not a formal model.
70
70
71
71
Key properties are:
72
72
73
- - ** volatility (V)** - Any written value is immediately visible to any
74
- subsequent volatile read of the same variable. Any write executed before
75
- volatile write based on program-order is visible to the read as well, which
76
- allows
77
- [ piggybacking] ( http://stackoverflow.com/questions/8769570/volatile-piggyback-is-this-enough-for-visiblity ) .
78
- (Same meaning as in Java, it creates synchronizes-with (JMM term) order
79
- between write and read, which participates in creating happens-before
80
- order.)
73
+ - ** volatility (V)** - A written value is immediately visible to any
74
+ subsequent volatile read of the same variable on any Thread. (It has same
75
+ meaning as in Java.)
81
76
- ** atomicity (A)** - Operation is either done or not as a whole.
82
77
- ** serialized (S)** - Operations are serialized in some order (they
83
78
cannot disappear). This is a new property not mentioned in other memory
You can’t perform that action at this time.
0 commit comments