Date: Wed, 08 May 2024 22:38:34 -0700
On Wednesday 8 May 2024 21:44:20 GMT-7 anshul mittal via Std-Proposals wrote:
> When a single thread tries locking on the same mutex std::mutex it creates
> a deadlock. This situation can arise in some projects and it arose for me.
That means it's a bug in your code. You should fix your code. A mutex silently
not locking and reporting success is a horrible idea because the number of
unlocks will now be unpaired.
Maybe you want to use std::recursive_mutex and argue with your code reviewers
that this is the correct solution for your problem. In many projects I know of
(but not all), use of a recursive mutex is an automatic rejection.
> When a single thread tries locking on the same mutex std::mutex it creates
> a deadlock. This situation can arise in some projects and it arose for me.
That means it's a bug in your code. You should fix your code. A mutex silently
not locking and reporting success is a horrible idea because the number of
unlocks will now be unpaired.
Maybe you want to use std::recursive_mutex and argue with your code reviewers
that this is the correct solution for your problem. In many projects I know of
(but not all), use of a recursive mutex is an automatic rejection.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Cloud Engineering
Received on 2024-05-09 05:38:42