diff options
| author | Russ Cox <rsc@golang.org> | 2022-01-26 16:53:50 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-06-06 20:48:03 +0000 |
| commit | a71ca3dfbd32faf351ff68bcc26a4d5abd9b06d7 (patch) | |
| tree | 0523f7aeacea7089b127ea3a8e5e58dded85fa0e /src/sync/map.go | |
| parent | 3651a6117e9a88576615c29c4faf7eeec55d7691 (diff) | |
| download | go-a71ca3dfbd32faf351ff68bcc26a4d5abd9b06d7.tar.xz | |
runtime, sync, sync/atomic: document happens-before guarantees
A few of these are copied from the memory model doc.
Many are entirely new, following discussion on #47141.
See https://research.swtch.com/gomm for background.
The rule we are establishing is that each type that is meant
to help synchronize a Go program should document its
happens-before guarantees.
For #50859.
Change-Id: I947c40639b263abe67499fa74f68711a97873a39
Reviewed-on: https://go-review.googlesource.com/c/go/+/381316
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src/sync/map.go')
| -rw-r--r-- | src/sync/map.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sync/map.go b/src/sync/map.go index 2fa3253429..ec529e056b 100644 --- a/src/sync/map.go +++ b/src/sync/map.go @@ -24,6 +24,13 @@ import ( // contention compared to a Go map paired with a separate Mutex or RWMutex. // // The zero Map is empty and ready for use. A Map must not be copied after first use. +// +// In the terminology of the Go memory model, Map arranges that a write operation +// “synchronizes before” any read operation that observes the effect of the write, where +// read and write operations are defined as follows. +// Load, LoadAndDelete, LoadOrStore are read operations; +// Delete, LoadAndDelete, and Store are write operations; +// and LoadOrStore is a write operation when it returns loaded set to false. type Map struct { mu Mutex |
