C++ (Qt)#ifndef CMUTEX_H#define CMUTEX_H #include <QMutex>#include <QThread> class CMutex {public: CMutex( void ) : mOwner(0) {} void Lock( void ) { mMutex.lock(); mOwner = QThread::currentThread(); } void Unlock( void ) { mOwner = 0; mMutex.unlock(); } QThread * GetOwner( void ) const { return mOwner; } private: QThread * mOwner; QMutex mMutex;}; #endif // CMUTEX_H
void GetOwner( void ) const { return mOwner; }
C++ (Qt)// Thread 1if (mutex.GetOwner() == someValue).. <- пробой // Thread 2mOwner = QThread::currentThread(); // в методе CMutex::Lock