Explain the exact internal implementation of a thread-safe reference counter such as Rust's Arc, and how it manages atomic operations under the hood.