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. QThread & QMutex
Forum Updated to NodeBB v4.3 + New Features

QThread & QMutex

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 840 Views 2 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.
  • V Offline
    V Offline
    VeNToR
    wrote on last edited by
    #1

    How do you know that the thread has already mutexed ? QThread::isRunning is not answer...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use tryLock for example.

      Out of curiosity, what is your use case ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VeNToR
        wrote on last edited by VRonin
        #3

        @SGaist said in QThread & QMutex:

        Out of curiosity, what is your use case ?

        Hi;

        tryLock always returns true.

        	// RSM is own object (Remote Service Manager.  It likes OO-RPC (and likes Qt Remote Object).
        	CChRSM
        	{
        		id	: chRSM
        	}
        
        	CChRSMNetworkAccessManager
        	{
        		id			: chTestx
        
        		chRSM		: chRSM
        	}
        
        	Loader
        	{
        		id		: chLoaderPage
        			
        		source	: "rsmfile:///Content/ChPageTest.ui.qml"
        
        		// if true, everthing ok !!!
        		//asynchronous: true
        
        		onLoaded:
        		{
        			item.chRSM = chRSM;
        		}
        	}
        
        QNetworkAccessManager* CChQMLRSMNetworkAccessManagerFactory::create(
        	QObject*	ChParent)
        {
        	// dead lock occurs here, cause'f m_ChQMLRSM is in main thread and locked !
        	m_ChQMLRSM->ChGetSessionInfo();
        ....
        }
        
        1 Reply Last reply
        0
        • BuckwheatB Offline
          BuckwheatB Offline
          Buckwheat
          wrote on last edited by
          #4

          @VeNToR said in QThread & QMutex:

          ck always returns true.

          Hi @VeNToR!

          By chance is your mutex created using QMutex::Recursive and are you using tryLock in the same thread?

          from QMutex documentation:
          "Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a recursive mutex. If this mutex is a non-recursive mutex, this function will always return false when attempting to lock the mutex recursively."

          Dave Fileccia

          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