Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-119837

QMutex: Part of documentation indicated that the lock is reentrant

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2
    • Core: QtConcurrent
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            anloth An Loth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes