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. Does QWaitCondition::wait locks the mutex again?
Forum Updated to NodeBB v4.3 + New Features

Does QWaitCondition::wait locks the mutex again?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 408 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.
  • H Offline
    H Offline
    HenryGer
    wrote on last edited by HenryGer
    #1

    Accroding to doc
    the QWaitCondition::wait unlocks the mutex, but in the same doc there is example

    forever {
        mutex.lock();
        keyPressed.wait(&mutex);
        do_something();
        mutex.unlock();
    }
    

    in the last line the mutex is unlocked again. Why?? Does QWaitCondition::wait locks it again?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fmedlin
      wrote on last edited by
      #2

      Yes, it does. In the docs for QWaitCondition::wait()

      The lockedMutex will be returned to the same locked state. This function is provided to allow the atomic transition from the locked state to the wait state.
      
      1 Reply Last reply
      2

      • Login

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