isocpp / isocpp/CppCoreGuidelines

CP.22 suggests a recursive mutex can solve a broken design

Open
#871 4 comments 5 reactions 1 assignee View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.