Skip to content

Commit f33f7a7

Browse files
committed
Clarify conflicting access (#319)
If you conceptualize access as being either a read or a write, and either atomic or nonatomic, the old and new wording means the same thing. However, if you divide access into three categories — read, write, and atomic — the old wording meant something different from the new wording, and was incorrect. This change avoids the opportunity for misunderstanding. Fixes: rdar://123389673
2 parents f315812 + 3cfdb5c commit f33f7a7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

TSPL.docc/LanguageGuide/MemorySafety.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Specifically,
138138
a conflict occurs if you have two accesses
139139
that meet all of the following conditions:
140140

141-
- At least one is a write access or a nonatomic access.
141+
- The accesses aren't both reads, and aren't both atomic.
142142
- They access the same location in memory.
143143
- Their durations overlap.
144144

@@ -152,13 +152,18 @@ for example, a variable, constant, or property.
152152
The duration of a memory access
153153
is either instantaneous or long-term.
154154

155-
An operation is *atomic*
156-
if it uses only C atomic operations;
155+
An access is *atomic* if
156+
it's a call to an atomic operation on [`Atomic`] or [`AtomicLazyReference`],
157+
or it it uses only C atomic operations;
157158
otherwise it's nonatomic.
158-
For a list of those functions, see the `stdatomic(3)` man page.
159+
For a list of C atomic functions, see the `stdatomic(3)` man page.
160+
161+
[`Atomic`]: https://developer.apple.com/documentation/synchronization/atomic
162+
[`AtomicLazyReference`]: https://developer.apple.com/documentation/synchronization/atomiclazyreference
159163

160164
<!--
161-
Using these functions from Swift requires some shimming -- for example:
165+
Using the C atomic functions from Swift
166+
requires some shimming that's out of scope for TSPL - for example:
162167
https://github.com/apple/swift-se-0282-experimental/tree/master/Sources/_AtomicsShims
163168
-->
164169

0 commit comments

Comments
 (0)