Add an atomic Boolean type (#4)

* Add an atomic Boolean type

Fixes #2.

* Feedback from CR

- Rename Swap to Toggle
- Add a more Swap-like Swap

* Add boolToInt helper
3 files changed
tree: 913594e805943fed983a144bc28b8aa80ed95938
  1. .github/
  2. scripts/
  3. .gitignore
  4. .travis.yml
  5. atomic.go
  6. atomic_test.go
  7. example_test.go
  8. glide.lock
  9. glide.yaml
  10. LICENSE.txt
  11. Makefile
  12. README.md
  13. stress_test.go
README.md

atomic GoDoc Build Status Coverage Status

Simple numeric wrappers to enforce atomic access.

Installation

go get -u github.com/uber-go/atomic

Usage

The standard library‘s sync/atomic is powerful, but it’s easy to forget which variables must be accessed atomically. uber-go/atomic preserves all the functionality of the standard library, but wraps the primitive numeric types to provide a safer, more convenient API.

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

See the documentation for a complete API specification.

Development Status

Stable.