Atomics – the Primitives of Synchronization

In Chapter 4, Sync and Send – the Foundation of Rust Concurrency, and Chapter 5, Locks – Mutex, Condvar, Barriers and RWLock, we discussed the fundamentals of lock-based concurrency in Rust. However, there are some cases where lock-based programming is not suitable, such as when extreme performance is a concern or threads may never block. In such domains, the programmer must rely on the atomic synchronization primitives of modern CPUs.

In this chapter, we'll be discussing the atomic primitives available to the Rust programmer. Programming with atomics is a complex topic and an area of active research. An entire book could be dedicated to the topic of atomic Rust programming. As such, we'll be shifting ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.