Re:Go CheckLocks Analyzer
by JulienSchmidt on Thursday December 30, 2021 @04:39AM
(#29735178)
At least for atomic access, I still believe that using wrapper types that prevent non-atomic access are the better idea: e.g. https://github.com/julienschmidt/atom (or uber/atomic).
That already ensures safe access at dev / compile-time. One explicitly states on declaration that the variable is accessed atomically by using the wrapper type.
A linter could then simply check that sync/atomic isn't used directly anywhere.
Re:Go CheckLocks Analyzer
by amscanne on Thursday December 30, 2021 @11:17AM
(#29737952)
Note that this also exists in the gVisor code base, the atomics support here is mostly for mixed-mode operation (read atomic, write locked) which is also common. It’s pretty new, so I still need to annotate a lot of the code.
That already ensures safe access at dev / compile-time. One explicitly states on declaration that the variable is accessed atomically by using the wrapper type. A linter could then simply check that sync/atomic isn't used directly anywhere.