isocpp / isocpp/CppCoreGuidelines
CP.22 suggests a recursive mutex can solve a broken design
Open
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
The guideline about not calling unknown code while holding a lock is good, but the example that says "Such problem can often be solved by using a recursive_mutex" is not good. Recursive mutexes are a code smell, not a solution.
I don't have a suggestion for improvement.
Separate to the recursive mutex aspect, the first example could be extended to cover the case of templates, where the template argument can run arbitrary code in constructors and destructors. These aren't usually thought of a "callbacks" but they are certainly "unknown code", so worth calling out explicitly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.