-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 (*Value).Swap and (*Value).CompareAndSwap
The functions SwapPointer and CompareAndSwapPointer can be used to interact with unsafe.Pointer, however generally it is prefered to work with Value, due to its safer interface. As such, they have been added along with glue logic to maintain invariants Value guarantees. To meet these guarantees, the current implementation duplicates much of the Store function. Some of this is due to inexperience with concurrency and desire for correctness, but the lack of generic programming functionality does not help. Fixes #39351 Change-Id: I1aa394b1e70944736ac1e19de49fe861e1e46fba Reviewed-on: https://go-review.googlesource.com/c/go/+/241678 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
- Loading branch information
Showing
2 changed files
with
257 additions
and
11 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
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