Discussions about the future of atomic primitives in rust

FWIW, we have an obvious name to use for a type exposing atomic operations on arbitrary types: AtomicCell.

Even in the face of being able to provide the atomic API for larger types, it is of significant benefit to provide a type which only does so for types which can (reasonably portably) be made atomic in a lock-free manner, i.e. for which the CPU provides a way to manipulate them in memory in a synchronized atomic manner.

Any type which can be marshalled into an atomic primitive should be usable in std Atomic<T>, imho. But I don't think std needs to provide AtomicCell<T> when it provides Mutex<T>; AtomicCell can be left to ecosystem crates like crossbeam because it isn't a critical piece of vocabulary or platform abstraction like Atomic and Mutex are.

2 Likes