recursive-mutex Questions

4

Solved

I have seen some people hate on recursive_mutex: http://www.zaval.org/resources/library/butenhof1.html But when thinking about how to implement a class that is thread safe (mutex protected), it s...
Caulk asked 24/1, 2013 at 10:19

8

Solved

I understand recursive mutex allows mutex to be locked more than once without getting to a deadlock and should be unlocked the same number of times. But in what specific situations do you need to u...
Rhapsodic asked 10/3, 2010 at 7:1

3

Solved

I have this class (simplified): // thing.h #include <mutex> class Thing { public: void process(); void inner(); private: std::mutex lock; }; // thing.cpp #include "Thing.h" using na...
Amaro asked 16/10, 2017 at 9:50

8

Solved

POSIX allows mutexes to be recursive. That means the same thread can lock the same mutex twice and won't deadlock. Of course it also needs to unlock it twice, otherwise no other thread can obtain t...
Golden asked 9/10, 2008 at 15:19

2

Solved

Does pthreads support any method that allows you to query the number of times a recursive mutex has been locked?
Dowery asked 11/11, 2009 at 21:12

1

Solved

I have a case where my algorithm's decisions are based on the depth of a shared std::recursive_mutex. #include <iostream> #include <mutex> #include <thread> int g_i = 0; std::re...
Hounding asked 26/9, 2017 at 11:21

1

Solved

I was wondering what happens when you move a unique_lock that holds a recursive_mutex. Specifically, I was looking at this code: recursive_mutex g_mutex; #define TRACE(msg) trace(__FUNCTION__, m...
Exserviceman asked 18/7, 2016 at 13:44

1

Quoting [thread.mutex.recursive]: A thread that owns a recursive_mutex object may acquire additional levels of ownership by calling lock() or try_lock() on that object. It is unspecified how man...
Tuque asked 13/5, 2016 at 7:24

1

According the this, unique_lock can be used for recursive locking by declaring a std::unique_lock<std::recursive_mutex>, and in fact that compiles fine. However, it appears from examining th...
Rubdown asked 23/12, 2014 at 18:50

3

Solved

I'm trying to use a recursive QMutex, i read the QMutex Class Reference but i not understand how to do it, can someone give me an example? I need some way to lock QMutex that can be unlocked after ...
Ulick asked 30/11, 2012 at 1:47

2

Solved

Can you combine std::recursive_mutex with std::condition_variable, meaning do something like this: std::unique_lock<std::recursive_mutex> lock(some_recursive_mutex) some_condition_var.wait(l...
Reinert asked 14/1, 2013 at 17:18

4

Solved

I am a bit confused on how to declare a recursive mutex using pthread. What I try to do is have only one thread at a time be able to run a piece of code(including functions) but after scepticism I ...
Cyprio asked 12/8, 2011 at 8:30
1

© 2022 - 2024 — McMap. All rights reserved.