Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMutexLocker - locking question

QMutexLocker - locking question

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmutexqmutexlocker
5 Posts 3 Posters 901 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    So I have a QMutexLocker l(&mLock);

    When this function gets called and mLock is already locked by another thread. What happens?

    1. The program stops & try-lock/wait forever until he can access the mutex to lock it?
    2. The program stops and does nothing.

    I'm trying to debug app locks :- )

    TIA!

    JonBJ 1 Reply Last reply
    0
    • D Dariusz

      Hey

      So I have a QMutexLocker l(&mLock);

      When this function gets called and mLock is already locked by another thread. What happens?

      1. The program stops & try-lock/wait forever until he can access the mutex to lock it?
      2. The program stops and does nothing.

      I'm trying to debug app locks :- )

      TIA!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Dariusz
      I assume it does as per QMutextLocker::lock(), i.e. block and wait.

      1 Reply Last reply
      2
      • D Offline
        D Offline
        Dariusz
        wrote on last edited by
        #3

        So if its already locked, then it waits? Will it try again locking or its just in waiting mode?

        JonBJ 1 Reply Last reply
        0
        • D Dariusz

          So if its already locked, then it waits? Will it try again locking or its just in waiting mode?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Dariusz
          I believe it will block/wait and then lock and continue as & when the mutex gets unlocked. But you should test.

          1 Reply Last reply
          3
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Dariusz said in QMutexLocker - locking question:

            So if its already locked, then it waits?

            This is exactly what a mutex is build for...

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            3

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved