diff options
Diffstat (limited to 'src/sync/atomic')
| -rw-r--r-- | src/sync/atomic/value.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sync/atomic/value.go b/src/sync/atomic/value.go index ab3aa11285..30abf72634 100644 --- a/src/sync/atomic/value.go +++ b/src/sync/atomic/value.go @@ -12,7 +12,11 @@ import ( // Values can be created as part of other data structures. // The zero value for a Value returns nil from Load. // Once Store has been called, a Value must not be copied. +// +// A Value must not be copied after first use. type Value struct { + noCopy noCopy + v interface{} } @@ -83,3 +87,13 @@ func (v *Value) Store(x interface{}) { // Disable/enable preemption, implemented in runtime. func runtime_procPin() func runtime_procUnpin() + +// noCopy may be embedded into structs which must not be copied +// after the first use. +// +// See https://github.com/golang/go/issues/8005#issuecomment-190753527 +// for details. +type noCopy struct{} + +// Lock is a no-op used by -copylocks checker from `go vet`. +func (*noCopy) Lock() {} |
