8 Advanced concurrency control
No more deadlocks!
This chapter covers
- Atoms as an alternative to locks
- Managing a thread-safe counter and a thread-safe in-memory cache with atoms
- Managing the whole system state in a thread-safe way with atoms
The traditional way to manage concurrency in a multi-threaded environment involves lock mechanisms like mutexes. Lock mechanisms tend to increase the complexity of the system because it’s not trivial to make sure the system is free of deadlocks. In DOP, we leverage the fact that data is immutable, and we use a lock-free mechanism, called an atom, to manage concurrency. Atoms are simpler to manage than locks because they are lock-free. As a consequence, the usual complexity of locks that are required to ...
Get Data-Oriented Programming 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.