Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2
-
None
Description
The documentation says
The purpose of a QMutex is to protect an object, data structure or section of code so that only one thread can access it at a time (this is similar to the Java synchronized keyword).
If another thread has locked the mutex then this call will block until that thread has unlocked it.
Java's synchronized is reentrant. Also the talking about other threads can lead to the conclusion that the lock is reentrant.
The sentence
Calling this function multiple times on the same mutex from the same thread will cause a dead-lock.
then states that the lock is not reentrant.
I suggest to rephrase the other sentences so that no confusion arises about reentrant or not:
The purpose of a QMutex is to protect an object, data structure or section of code so that after locking the mutex every other locking attempt will block until the mutex is unlocked. So, the one successfully locking the mutex has exclusive access to the protected resources. This is similar to the Java synchronized keyword but in contrast to synchronized, QMutex is not reentrant.
If the mutex is locked (from the current or another thread) then this call will block until the mutex is unlocked.