Tag: cplusplus
-
Review of Embracing Modern C++ Safely by John Lakos, Vittorio Romeo, Rostislav Khlebnikov and Alisdair Meredith
Verdict: Conditionally Recommended (3/5) This is a huge book, over 1300 pages, and contains a wealth of information about all the language (not library) facilities added in C++11 and C++14. It has one "section" per language feature, and …
-
Using atomics for thread synchronization in C++
In my previous blog post I wrote about spin locks, and how compilers must not move the locking loop above a prior unlock. After thinking about this done more, I realised that is not something specific to locks — the same issue arises with any two…
-
Can non-overlapping spinlocks deadlock in C++?
There has been discussion on Twitter recently about whether or not the C++ memory model allows spinlocks to deadlock if they just use memory_order_acquire in lock and memory_order_release in unlock, due to compiler optimizations. The case in question i…
-
Ticket Maps
It has been an increasingly common scenario that I’ve encountered where you have some ID that’s monotonically increasing, such as a subscription or connection index, or user ID, and you need your C++ program to hold some data that’s associated with tha…
-
Invariants and Preconditions
I tend to think about invariants and preconditions a lot. Pretty much every class has invariants, and most functions have preconditions. I don’t think they are complicated concepts, but somehow they seem to confuse people anyway, so I decided it was ti…