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. QMutext ignores errors?
Qt 6.11 is out! See what's new in the release blog

QMutext ignores errors?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.5k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    googie
    wrote on last edited by
    #1

    Hi,

    I wonder why QMutex ignores any initialization errors from pthread_mutex_init() (or its Windows platform equivalent)?

    If there was any problem, it just prints warning and keeps going, so then the lock() call will be executed on the invalid mutex, won't it?

    Why don't we have any "isOk()" method to check if the initialization went okay?
    For example the QThread.wait() returns bool, which already is enough to indicate a problem (timeout or any other problem). Why not having any information from QMutex?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      QReadWriteLock has!

      1 Reply Last reply
      0
      • G Offline
        G Offline
        googie
        wrote on last edited by
        #3

        QMutex and QReadWriteLock are not the same thing and it still doesn't explain why QMutex kind of "ignores" failed initialization.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          NicuPopescu
          wrote on last edited by
          #4

          @QMutex kind of “ignores” failed initialization.@

          if you have a look inside qt's mutex src you'll find out it actually does assertions internally

          bq. QMutex and QReadWriteLock are not the same thing

          and so the other ones :) ... the question is which of them is more appropriate and when, which gives better chance for threads synchronization and concurrency?

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            No specific reason, I'd imagine, except that the developers never found a need for it. This is a forum of Qt users, who likely can't comment on design decisions. If you want to ask a Qt engineer directly, you can subscribe to the "Interest mailing list":http://lists.qt-project.org/mailman/listinfo/interest and ask there.

            Anyway, what is your mutex for? Would you consider a more robust architecture which "doesn't need locks":http://doc-snapshot.qt-project.org/qt5-stable/threads-synchronizing.html#high-level-event-queues?

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0

            • Login

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