Commit Graph

5 Commits

Author SHA1 Message Date
Daniel Malmer
fcb7ed1e69 Add JSON Marshal and Unmarshal (#68)
Support serializing and deserializing atomic objects to/from JSON using
the JSON representation of the underlying types. Without this,
marshaling returns `{}`.

Per discussion in #68, `atomic.Value` does not yet implement support
because there's an open question as to whether it should implement it
even if the underlying type doesn't support JSON marshaling/
unmarshaling.

Resolves #49
2020-05-10 07:17:21 -07:00
Prashant Varanasi
e81582a97d 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 16b44f14f0.
2017-11-14 08:16:11 -08:00
Bill Fumerola
16b44f14f0 Optimization for String.Store("") 2017-07-19 18:44:22 -04:00
Prashant Varanasi
d938bba906 Fix NewString disregarding the passed in string 2016-07-18 11:07:34 -07:00
Prashant Varanasi
fecc23564a Add String as a type-safe wrapper for atomic.Value 2016-07-17 12:43:23 -07:00