data: Fixed files being consumed by multiple threads

This commit is contained in:
Eberhard Graether
2016-06-11 02:25:19 +02:00
parent 6821fd1c9a
commit c5af4ed4e5
2 changed files with 26 additions and 27 deletions
+24 -26
View File
@@ -99,46 +99,44 @@ bool FileRegister::fileIsParsed(const FilePath& filePath) const
bool FileRegister::sourceFileIsParsed(const FilePath& filePath) const
{
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
std::map<FilePath, ParseState>::const_iterator it = m_sourceFilePaths.find(filePath);
if (it == m_sourceFilePaths.end())
{
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
std::map<FilePath, ParseState>::const_iterator it = m_sourceFilePaths.find(filePath);
if (it == m_sourceFilePaths.end())
{
return false;
}
if (it->second == STATE_PARSED)
{
return true;
}
return false;
}
if (it->second == STATE_PARSED)
{
return true;
}
return false;
}
bool FileRegister::includeFileIsParsed(const FilePath& filePath) const
{
std::lock_guard<std::mutex> lock(m_includeFileMutex);
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
if (it == m_includeFilePaths.end())
{
std::lock_guard<std::mutex> lock(m_includeFileMutex);
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
if (it == m_includeFilePaths.end())
{
return false;
}
if (it->second == STATE_PARSED)
{
return true;
}
return false;
}
if (it->second == STATE_PARSED)
{
return true;
}
return false;
}
FilePath FileRegister::consumeSourceFile()
{
std::lock_guard<std::mutex> lock(m_consumeFileMutex);
std::vector<FilePath> paths = getUnparsedSourceFilePaths();
FilePath path;
+2 -1
View File
@@ -65,7 +65,8 @@ private:
mutable std::mutex m_sourceFileMutex;
mutable std::mutex m_includeFileMutex;
mutable std::mutex m_threadFileMutex;
mutable std::mutex m_fileManagerMutex;
std::mutex m_consumeFileMutex;
};
#endif // FILE_REGISTER_H