Hi,
I have this situation:
One thread class that needs to protect a QQueue but also needs to return dequeued value.
bool myThread::getResult()
{
m_qMutex.lock();
return m_qQueue.dequeue();
m_qMutex.unlock(); //This will never be executed because of return statment, and will cause a deadlock
}
bool myThread::getResult()
{
m_qMutex.lock();
return m_qQueue.dequeue();
m_qMutex.unlock(); //This will never be executed because of return statment, and will cause a deadlock
}
To copy to clipboard, switch view to plain text mode
So, how can I do this in a correct way. One solution is to get the mutex of the thread from the caller object and lock and unlock there but I want to know if there is a more elegant solution.
Thanks,
Bookmarks