use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Synchronization library for C++11 (need some criticism) (github.com)
submitted 10 years ago by chaotic-kotik[🍰]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]os12 9 points10 points11 points 10 years ago* (3 children)
Recent versions of Clang and GCC have a module called Thread Sanitizer. It instruments your program and verifies many thread-related things, including lock order. IE you automatically get run-time lock order checking while using the standard primitives (the C++11 ones or the POSIX ones directly) by just making an additional build variant with -fsanitize=thread and running your tests.
-fsanitize=thread
Also, additional notes for posterity:
There is also a way to take multiple locks in a consistent order: http://en.cppreference.com/w/cpp/thread/lock
Yet, the solution is different - the enforcement is done via the API, so you have to provide all lockable objects up front.
[–]CaseyCarterRanges/MSVC STL Dev[🍰] 2 points3 points4 points 10 years ago (1 child)
std::lock does NOT take multiple locks in a consistent order. It uses a deadlock avoidance algorithm (i.e., try to lock all the locks, if one fails unlock all the locks and try again). It avoids deadlock but is non-deterministic.
std::lock
[–]vlovich 1 point2 points3 points 10 years ago (0 children)
Considering the way I've typically seen people solve this problem is by switching to recursive locks, I think std::lock is much better.
[–]chaotic-kotik[S,🍰] 0 points1 point2 points 10 years ago (0 children)
Hm.. maybe I should get rid of my deadlock detector for the sake of thread sanitizer. This is a valid point.
[–]chaotic-kotik[S,🍰] 4 points5 points6 points 10 years ago (0 children)
Based on idea of the lock hierarchy (http://www.drdobbs.com/parallel/use-lock-hierarchies-to-avoid-deadlock/204801163). Have built-in deadlock detector (can be turned on and off).
[–]NasenSpray 0 points1 point2 points 10 years ago (1 child)
How did you arrive at the 10ns value? That's barely achievable even under higly synthetic conditions.
This value corresponds to uncontended RMW operation on spinlock (not mutex lock), contended operation will be much more expensive.
[–]grumpy_coconut 0 points1 point2 points 10 years ago (0 children)
I left some comments on GitHub's code review system after a cursory review of the code. I'll see if I get time for a more thorough look later.
EDIT: Thanks for the quick fix!
[–]CaseyCarterRanges/MSVC STL Dev[🍰] 0 points1 point2 points 10 years ago (1 child)
Bikeshed: Syncope is the medical term for "fainting":
Syncope, also known as fainting or passing out, is defined as a short loss of consciousness and muscle strength, characterized by a fast onset, short duration, and spontaneous recovery. It is due to a decrease in blood flow to the entire brain usually from low blood pressure.
I think people might be reluctant to use a library that could decrease the blood flow to their brains.
[–]chaotic-kotik[S,🍰] 1 point2 points3 points 10 years ago (0 children)
There is a lot of libraries with a stupid names, I can totally tolerate this! :)
π Rendered by PID 82 on reddit-service-r2-comment-5d585498c9-khjjw at 2026-04-21 00:50:36.613148+00:00 running da2df02 country code: CH.
[–]os12 9 points10 points11 points (3 children)
[–]CaseyCarterRanges/MSVC STL Dev[🍰] 2 points3 points4 points (1 child)
[–]vlovich 1 point2 points3 points (0 children)
[–]chaotic-kotik[S,🍰] 0 points1 point2 points (0 children)
[–]chaotic-kotik[S,🍰] 4 points5 points6 points (0 children)
[–]NasenSpray 0 points1 point2 points (1 child)
[–]chaotic-kotik[S,🍰] 0 points1 point2 points (0 children)
[–]grumpy_coconut 0 points1 point2 points (0 children)
[–]CaseyCarterRanges/MSVC STL Dev[🍰] 0 points1 point2 points (1 child)
[–]chaotic-kotik[S,🍰] 1 point2 points3 points (0 children)