diff --git a/src/lib/utility/file/FileRegister.cpp b/src/lib/utility/file/FileRegister.cpp index 4cb24428..d679b10f 100644 --- a/src/lib/utility/file/FileRegister.cpp +++ b/src/lib/utility/file/FileRegister.cpp @@ -138,18 +138,16 @@ bool FileRegister::includeFileIsParsed(const FilePath& filePath) const FilePath FileRegister::consumeSourceFile() { + std::vector paths = getUnparsedSourceFilePaths(); + FilePath path; + + if (paths.size()) { + path = paths[rand() % paths.size()]; + std::lock_guard lock(m_sourceFileMutex); - for (std::map::iterator it = m_sourceFilePaths.begin(); it != m_sourceFilePaths.end(); it++) - { - if (it->second == STATE_UNPARSED) - { - it->second = STATE_PARSING; - path = it->first; - break; - } - } + m_sourceFilePaths[path] = STATE_PARSING; } if (!path.empty())