mirror of
https://github.com/golang/go
synced 2024-11-26 03:07:57 -07:00
sync: document memory model for Swap/CompareAnd{Swap,Delete} in Map
CL 381316 documented the memory model of Map's APIs. However, the newly introduced Swap, CompareAndSwap, and CompareAndDelete are missing from this documentation as CL 399094 did not add this info. This CL specifies the defined read/write operations of the new Map APIs. For #51972 Change-Id: I519a04040a0b429a3f978823a183cd62e42c90ae Reviewed-on: https://go-review.googlesource.com/c/go/+/459715 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Changkun Ou <mail@changkun.de> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
5724daa682
commit
f07910bd57
@ -27,9 +27,11 @@ import (
|
||||
// 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.
|
||||
// Load, LoadAndDelete, LoadOrStore, Swap, CompareAndSwap, and CompareAndDelete
|
||||
// are read operations; Delete, LoadAndDelete, Store, and Swap are write operations;
|
||||
// LoadOrStore is a write operation when it returns loaded set to false;
|
||||
// CompareAndSwap is a write operation when it returns swapped set to true;
|
||||
// and CompareAndDelete is a write operation when it returns deleted set to true.
|
||||
type Map struct {
|
||||
mu Mutex
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user