Wrapper types for sync/atomic which enforce atomic access
Go to file
mleku 9a1bcde396
downgrading to 1.20
2024-02-18 21:04:30 +00:00
.github Minimize permissions to CI workflows (#133) 2023-03-20 09:52:44 -07:00
internal Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
tools updated to new domain 2024-02-18 20:38:35 +00:00
.codecov.yml make: Ignore coverage for generator scripts 2020-05-12 11:30:23 -07:00
.gitignore updating to gitignore allowlist 2024-02-18 20:42:36 +00:00
CHANGELOG.md Back to development (#137) 2023-05-03 14:32:19 -07:00
LICENSE.txt Add docs and linters before release (#6) 2016-05-29 20:50:32 -07:00
Makefile changing urls for new repo 2023-11-24 10:40:32 +00:00
README.md changing urls for new repo 2023-11-24 10:40:32 +00:00
assert_test.go all: go fmt ./... with go1.19 (#110) 2022-08-05 09:14:45 -07:00
bool.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
bool_ext.go Improve argument/return names for better docs (#96) 2021-06-11 10:20:12 -07:00
bool_test.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
doc.go Separate files for each atomic type 2020-05-15 15:47:25 -07:00
duration.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
duration_ext.go Improve argument/return names for better docs (#96) 2021-06-11 10:20:12 -07:00
duration_test.go Separate files for each atomic type 2020-05-15 15:47:25 -07:00
error.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
error_ext.go Add CompareAndSwap and Swap, Deprecate CAS (#111) 2022-08-06 11:12:19 -07:00
error_test.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
example_test.go updated to new domain 2024-02-18 20:38:35 +00:00
float32.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
float32_ext.go Add CompareAndSwap and Swap, Deprecate CAS (#111) 2022-08-06 11:12:19 -07:00
float32_test.go Provide atomic type for float32 (#107) 2022-05-06 12:12:31 -07:00
float64.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
float64_ext.go Add CompareAndSwap and Swap, Deprecate CAS (#111) 2022-08-06 11:12:19 -07:00
float64_test.go Add Swap for Float64 (#94) 2021-06-11 08:23:41 -07:00
gen.go Add uintptr, unsafe.Pointer atomics (#90) 2021-06-08 17:44:58 -07:00
go.mod downgrading to 1.20 2024-02-18 21:04:30 +00:00
go.sum downgrading to 1.20 2024-02-18 21:04:30 +00:00
int32.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
int32_test.go Implement fmt.Stringer for atomic types (#76) 2020-05-14 16:26:08 -07:00
int64.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
int64_test.go Implement fmt.Stringer for atomic types (#76) 2020-05-14 16:26:08 -07:00
nocmp.go all: go fmt ./... with go1.19 (#110) 2022-08-05 09:14:45 -07:00
nocmp_test.go Drop use of deprecated ioutil package (#117) 2022-08-09 14:30:10 -07:00
pointer_go118.go Implement String method for pointers (#122) 2022-09-20 15:23:16 -07:00
pointer_go118_pre119.go Implement String method for pointers (#122) 2022-09-20 15:23:16 -07:00
pointer_go119.go Add Pointer[T] (#116) 2022-08-09 16:56:14 -07:00
pointer_test.go Implement String method for pointers (#122) 2022-09-20 15:23:16 -07:00
stress_test.go Add atomic.Time (#98) 2021-06-22 00:36:49 -07:00
string.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
string_ext.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
string_test.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
time.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
time_ext.go Add atomic.Time (#98) 2021-06-22 00:36:49 -07:00
time_test.go Add atomic.Time (#98) 2021-06-22 00:36:49 -07:00
uint32.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
uint32_test.go Implement fmt.Stringer for atomic types (#76) 2020-05-14 16:26:08 -07:00
uint64.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
uint64_test.go Implement fmt.Stringer for atomic types (#76) 2020-05-14 16:26:08 -07:00
uintptr.go Fix Swap and CompareAndSwap for Value wrappers (#130) 2023-02-06 01:17:57 -08:00
uintptr_test.go uintptr test: Fix overflow on architectures with 32-bit pointers (#100) 2021-07-09 09:22:17 -07:00
unsafe_pointer.go Add CompareAndSwap and Swap, Deprecate CAS (#111) 2022-08-06 11:12:19 -07:00
unsafe_pointer_test.go Add uintptr, unsafe.Pointer atomics (#90) 2021-06-08 17:44:58 -07:00
value.go Value: place nocmp zero-sized field first (#109) 2022-08-05 09:21:10 -07:00
value_test.go Separate files for each atomic type 2020-05-15 15:47:25 -07:00

README.md

atomic GoDoc Build Status Coverage Status Go Report Card

Simple wrappers for primitive types to enforce atomic access.

Installation

$ go get -u github.com/p9ds/atomic@v1

Legacy Import Path

As of v1.5.0, the import path github.com/p9ds/atomic is the only supported way of using this package. If you are using Go modules, this package will fail to compile with the legacy import path path github.com/uber-go/atomic.

We recommend migrating your code to the new import path but if you're unable to do so, or if your dependencies are still using the old import path, you will have to add a replace directive to your go.mod file downgrading the legacy import path to an older version.

replace github.com/uber-go/atomic => github.com/uber-go/atomic v1.4.0

You can do so automatically by running the following command.

$ go mod edit -replace github.com/uber-go/atomic=github.com/uber-go/atomic@v1.4.0

Usage

The standard library's sync/atomic is powerful, but it's easy to forget which variables must be accessed atomically. github.com/p9ds/atomic preserves all the functionality of the standard library, but wraps the primitive types to provide a safer, more convenient API.

var atom atomic.Uint32
atom.Store(42)
atom.Sub(2)
atom.CompareAndSwap(40, 11)

See the documentation for a complete API specification.

Development Status

Stable.


Released under the MIT License.