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. QReadWriteLock finding out whether it's write locked on same thread

QReadWriteLock finding out whether it's write locked on same thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 562 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.
  • P Offline
    P Offline
    Pavel Celba
    wrote on last edited by
    #1

    I have following problem for recursive QReadWriteLock. I have it potentially locked for writing and I'd like to find out whether current thread is one that has it locked for writing. Is there way to do it?

    This is to determine whether I need to read lock it or not on current thread.
    This is professional 3D viewing software and objects are geometries (100MB+ of data is not uncommon). The code is bloated and badly designed. I cannot really have any much better management and knowledge whether it's already locked on same thread or not. Therefore recursive read-write mutex must know it.

    Any other advices how to achieve this?

    P.s.: I only want to either read lock it or don't read lock it when it's write locked (on the same thread). No other things requested like - checking in general if mutex is locked. Or wanting to write lock it when it's read locked on same thread.

    If there are no ways how to achieve this. I'll likely write read-write mutex of my own with support for this.

    kshegunovK 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I don't understand your problem completely - why does a recursive QReadWriteLock not work for you?

      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
      • P Pavel Celba

        I have following problem for recursive QReadWriteLock. I have it potentially locked for writing and I'd like to find out whether current thread is one that has it locked for writing. Is there way to do it?

        This is to determine whether I need to read lock it or not on current thread.
        This is professional 3D viewing software and objects are geometries (100MB+ of data is not uncommon). The code is bloated and badly designed. I cannot really have any much better management and knowledge whether it's already locked on same thread or not. Therefore recursive read-write mutex must know it.

        Any other advices how to achieve this?

        P.s.: I only want to either read lock it or don't read lock it when it's write locked (on the same thread). No other things requested like - checking in general if mutex is locked. Or wanting to write lock it when it's read locked on same thread.

        If there are no ways how to achieve this. I'll likely write read-write mutex of my own with support for this.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @Pavel-Celba said in QReadWriteLock finding out whether it's write locked on same thread:

        I have following problem for recursive QReadWriteLock.

        Yes, the main problem is you're using recursive mutexes. Breaking ownership semantics ain't no fun.

        Is there way to do it?

        Not really no. You can tell if it's locked for writing by issuing a dummy tryLockForRead(1), but this won't tell you who locked it in the first place.

        Any other advices how to achieve this?

        Best advice - don't use recursive locking.

        If there are no ways how to achieve this. I'll likely write read-write mutex of my own with support for this.

        Smooth sailing!

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        2
        • P Offline
          P Offline
          Pavel Celba
          wrote on last edited by
          #4

          I have decided, I'll write my own mutex meeting my requirements.

          1 Reply Last reply
          1

          • Login

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