Skip to content

Commit 2b6a7bd

Browse files
committed
Simplify volatile definition
1 parent d018594 commit 2b6a7bd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

doc/synchronization-notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,13 @@ class Node
5252
# ...
5353
end
5454
```
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.

doc/synchronization.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ time-consuming and error-prone.
3434
The Ruby memory model is a framework allowing to reason about programs in
3535
concurrent and parallel environment. It defines what variable writes can be
3636
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
3838
all possible program execution orders is allowed.
3939

4040
A memory model sources:
@@ -70,14 +70,9 @@ C++11). This is not a formal model.
7070

7171
Key properties are:
7272

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.)
8176
- **atomicity (A)** - Operation is either done or not as a whole.
8277
- **serialized (S)** - Operations are serialized in some order (they
8378
cannot disappear). This is a new property not mentioned in other memory

0 commit comments

Comments
 (0)