Commit Graph

6 Commits

Author SHA1 Message Date
eNV25
d4bbbc828d Add CompareAndSwap and Swap, Deprecate CAS (#111)
Adds CompareAndSwap and Swap methods to String, Error, and Value,
implemented by making use of Value.CompareAndSwap and Value.Swap
added in Go 1.17.

Following that, add CompareAndSwap to all other types with "CAS" methods
and deprecate CAS in favor of CompareAndSwap, since that's the convention
the standard library chose for these in Go 1.19.
2022-08-06 11:12:19 -07:00
eNV25
976602f5dc all: go fmt ./... with go1.19 (#110) 2022-08-05 09:14:45 -07:00
Prashant Varanasi
d8a8972198 Improve argument/return names for better docs (#96)
This change is a renaming with no functional changes.

It includes the following renames:
 * `val` for arguments that replace the atomic value (e.g., `Store`).
 * `delta` for arguments that offset the atomic value (e.g., `Add`).
 * `old`, `new` for arguments to `CAS`.
 * `old` named return from `Swap`.
 * `swapped` for named return from `CAS`.

This also matches the names used in the stdlib atomic interface:
https://golang.org/pkg/sync/atomic/
2021-06-11 10:20:12 -07:00
Abhinav Gupta
2a929df6c0 generate: Use year range for license (#92)
The generators gen-atomicint and gen-atomicwrapper hard-coded the year
into the licenses of the generated files.

Update to generate year ranges for the licenses, starting at 2020, going
to whatever today's year is.
2021-06-08 11:27:37 -07:00
Abhinav Gupta
f64e592f7f staticcheck: Fix unused fields
The embedded `nocmp` field and other similar fields are unused in tests
and the rest of our code.

We can get the effect of `nocmp` without embedding the fields by using
`_ nocmp` as a field.
2020-09-11 11:24:56 -07:00
Abhinav Gupta
98666305b5 Generalize gen-valuewrapper into atomicwrapper
valuewrapper can be used only to generate atomic wrapper types for
types which are stored as atomic.Value. This isn't necessary because the
same logic can be applied to atomic wrappers built on other types like
Duration and Bool.

Generalize valuewrapper into atomicwrapper with support for optional
pack/unpack functions which handle conversion to/from `interface{}`.
This lets Error hook in and install the `storedError` struct (now called
`packedError`) to avoid panics from nil storage or value type change.
2020-05-15 15:47:21 -07:00