9
Atomic Memory Operations
Atomic memory operations provide the low-level foundation necessary to implement other synchronization primitives. In general, you can replace all atomic operations of a concurrent algorithm with mutexes and channels. Nevertheless, they are interesting and sometimes confusing constructs, and you should know how they work. If you use them carefully, they can become good tools for code optimization without increasing complexity.
In this chapter, we will explore the following topics:
- Memory guarantees of atomic memory operations
- The compare-and-swap operation
- Practical uses of atomics, including counters, heartbeats/progress meters, cancellations, and detecting change
Technical Requirements
The source code for this ...
Get Effective Concurrency in Go 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.