-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync/atomic: add typed atomic values
These implementations will inline to the lower-level primitives, but they hide the underlying values so that all accesses are forced to use the atomic APIs. They also allow the use of shorter names (methods instead of functions) at call sites, making code more readable. Pointer[T] also avoids conversions using unsafe.Pointer at call sites. Discussed on #47141. See also https://research.swtch.com/gomm for background. Fixes #50860. Change-Id: I0b178ee0c7747fa8985f8e48cd7b01063feb7dcc Reviewed-on: https://go-review.googlesource.com/c/go/+/381317 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
5 changed files
with
1,415 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
pkg sync/atomic, method (*Bool) CompareAndSwap(bool, bool) bool #50860 | ||
pkg sync/atomic, method (*Bool) Load() bool #50860 | ||
pkg sync/atomic, method (*Bool) Store(bool) #50860 | ||
pkg sync/atomic, method (*Bool) Swap(bool) bool #50860 | ||
pkg sync/atomic, method (*Int32) Add(int32) int32 #50860 | ||
pkg sync/atomic, method (*Int32) CompareAndSwap(int32, int32) bool #50860 | ||
pkg sync/atomic, method (*Int32) Load() int32 #50860 | ||
pkg sync/atomic, method (*Int32) Store(int32) #50860 | ||
pkg sync/atomic, method (*Int32) Swap(int32) int32 #50860 | ||
pkg sync/atomic, method (*Int64) Add(int64) int64 #50860 | ||
pkg sync/atomic, method (*Int64) CompareAndSwap(int64, int64) bool #50860 | ||
pkg sync/atomic, method (*Int64) Load() int64 #50860 | ||
pkg sync/atomic, method (*Int64) Store(int64) #50860 | ||
pkg sync/atomic, method (*Int64) Swap(int64) int64 #50860 | ||
pkg sync/atomic, method (*Pointer[$0]) CompareAndSwap(*$0, *$0) bool #50860 | ||
pkg sync/atomic, method (*Pointer[$0]) Load() *$0 #50860 | ||
pkg sync/atomic, method (*Pointer[$0]) Store(*$0) #50860 | ||
pkg sync/atomic, method (*Pointer[$0]) Swap(*$0) *$0 #50860 | ||
pkg sync/atomic, method (*Uint32) Add(uint32) uint32 #50860 | ||
pkg sync/atomic, method (*Uint32) CompareAndSwap(uint32, uint32) bool #50860 | ||
pkg sync/atomic, method (*Uint32) Load() uint32 #50860 | ||
pkg sync/atomic, method (*Uint32) Store(uint32) #50860 | ||
pkg sync/atomic, method (*Uint32) Swap(uint32) uint32 #50860 | ||
pkg sync/atomic, method (*Uint64) Add(uint64) uint64 #50860 | ||
pkg sync/atomic, method (*Uint64) CompareAndSwap(uint64, uint64) bool #50860 | ||
pkg sync/atomic, method (*Uint64) Load() uint64 #50860 | ||
pkg sync/atomic, method (*Uint64) Store(uint64) #50860 | ||
pkg sync/atomic, method (*Uint64) Swap(uint64) uint64 #50860 | ||
pkg sync/atomic, method (*Uintptr) Add(uintptr) uintptr #50860 | ||
pkg sync/atomic, method (*Uintptr) CompareAndSwap(uintptr, uintptr) bool #50860 | ||
pkg sync/atomic, method (*Uintptr) Load() uintptr #50860 | ||
pkg sync/atomic, method (*Uintptr) Store(uintptr) #50860 | ||
pkg sync/atomic, method (*Uintptr) Swap(uintptr) uintptr #50860 | ||
pkg sync/atomic, type Bool struct #50860 | ||
pkg sync/atomic, type Int32 struct #50860 | ||
pkg sync/atomic, type Int64 struct #50860 | ||
pkg sync/atomic, type Pointer[$0 interface{}] struct #50860 | ||
pkg sync/atomic, type Uint32 struct #50860 | ||
pkg sync/atomic, type Uint64 struct #50860 | ||
pkg sync/atomic, type Uintptr struct #50860 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.