yes, but then I am unable to use it along with QReadLocker.
However IMO isn't correct to make the lock functions const. They modify the internal state of the object
then how should i check my file list in another thread?
bool findFile()
{
const FileList &fileList = myclass->getFiles();
// need to protect fileList here
fileList.lockForRead();
// i don't modify file list here, but i need it to be protected from modification with something else
foreach (const MyFile &file, fileList)
{
//...
}
fileList.unlock();
}
bool findFile()
{
const FileList &fileList = myclass->getFiles();
// need to protect fileList here
fileList.lockForRead();
// i don't modify file list here, but i need it to be protected from modification with something else
foreach (const MyFile &file, fileList)
{
//...
}
fileList.unlock();
}
To copy to clipboard, switch view to plain text mode
Bookmarks