Commit Graph

3 Commits

Author SHA1 Message Date
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
Abhinav Gupta
08f23f163e Generate atomic Value wrappers automatically
Rather than hand-writing wrappers around atomic.Value, generate them
automatically from the same template. The generator is at
internal/gen-valuewrapper. The generator correctly handles generating
wrapper structs for nillable types.
2020-05-12 11:30:18 -07:00
Abhinav Gupta
d9a13c26a5 Generate atomic integers automatically
Rather than hand-writing the atomic integers, generate them
automatically from the same template. The generator is at
internal/gen-atomicint.

To ensure these are never out of date, add another `make` target which
verifies that the working tree is left unchanged after regenerating
code.
2020-05-12 11:30:09 -07:00