My shorthand, simplified class is as follows:
class A { public: // ... methodA(); methodB(); protected: mutable boost::mutex m_mutex; sometype* m_myVar; } A::methodA( int someParam ) { boost::mutex::scoped_lock myLock(m_mutex); m_myVar->doSomethingElse(); } A::methodB( int someParam ) { boost::mutex::scoped_lock myLock(m_mutex); m_myVar->doSomething(); this->methodA(someParam); }
I would like to synchronize access on m_myVar . When calling A::methodB() thread runs into the lock with the same mutex twice and, obviously, blocks the first line of A::methodA()
Is there a way to make scoped_lock not blocking one thread while re-passing?
Of course, I could just call m_mutex.unlock() . But this will free up other threads waiting for blocking, and this is not at all what I want.
Any idea?
Regards Tobias
source share