Sorry read to fast.
But you can do it your self.
For example, you can override QSharedMemory so:
// in the header:
bool m_bLocked;
//and
bool isLocked() {return m_bLocked; }
//in the implementation:
//initialize in the ctor
bool MyQSharedMemory::tryLock()
{
if(!m_bLocked){
m_bLocked = QSharedMemory::lock();
return m_bLocked;
}
return false;
}
// in the header:
bool m_bLocked;
//and
bool isLocked() {return m_bLocked; }
//in the implementation:
//initialize in the ctor
bool MyQSharedMemory::tryLock()
{
if(!m_bLocked){
m_bLocked = QSharedMemory::lock();
return m_bLocked;
}
return false;
}
To copy to clipboard, switch view to plain text mode
But I would go through the QSharedMemory doc thoroughly, as my guess is that the trolls didn't build it in in the first place because probably it conflicts with the way QSharedMemory work, and the way it should be used.
Since I didn't work with it yet, I can't say.
Another way is to use to protect the resource with a mutex, and only do something with it if you managed to lock the mutex.
if(mutex.tryLock()){
//Do something with resource
}
if(mutex.tryLock()){
//Do something with resource
}
To copy to clipboard, switch view to plain text mode
Bookmarks