Hacker News new | ask | show | jobs
by sesquipedalian 4017 days ago
This is one of those things that seems obvious in hindsight. However, it never occurred to me that one could simply use the lock address to impose a consistent and unique ordering on the locks rather than some other explicit mechanism. It's a rather clever solution, the pointer is the sequence number!
1 comments

Interestingly, in C and C++ the ordering of two pointers not pointing to the same array is not well-defined because the address space may not be flat. In C++ the standard function object std::less is specifically guaranteed to impose a total order on pointers even thought the builtin less-than operator does not.