Revert "Optimization for String.Store("")" (#32)

This optimization causes data races since we're changing the value field
without using atomics. E.g., a caller who has multiple goroutines
calling `Set("1")` and `Set("")` will race on the access to `s.v` since
one goroutine is trying to read it while the other sets it, neither
using atomic operations.

This reverts commit 16b44f14f0990d358f2ba3191ff8e7c44c9f0bef.
2 files changed
tree: bf99499509711dc74f03325d69be2fd0b98a9687
  1. .github/
  2. scripts/
  3. .codecov.yml
  4. .gitignore
  5. .travis.yml
  6. atomic.go
  7. atomic_test.go
  8. example_test.go
  9. glide.lock
  10. glide.yaml
  11. LICENSE.txt
  12. Makefile
  13. README.md
  14. stress_test.go
  15. string.go
  16. string_test.go
README.md

atomic GoDoc Build Status Coverage Status Go Report Card

Simple wrappers for primitive types to enforce atomic access.

Installation

go get -u go.uber.org/atomic

Usage

The standard library‘s sync/atomic is powerful, but it’s easy to forget which variables must be accessed atomically. go.uber.org/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.CAS(40, 11)

See the documentation for a complete API specification.

Development Status

Stable.