This commit is contained in:
parent
70ccfa5947
commit
fab2c96622
|
@ -352,10 +352,11 @@ unsigned int ThreadExecutor::check()
|
|||
HANDLE *threadHandles = new HANDLE[_settings.jobs];
|
||||
|
||||
_itNextFile = _files.begin();
|
||||
_itNextFileSettings = _settings.fileSettings.begin();
|
||||
|
||||
_processedFiles = 0;
|
||||
_processedSize = 0;
|
||||
_totalFiles = _files.size();
|
||||
_totalFiles = _files.size() + _settings.fileSettings.size();
|
||||
_totalFileSize = 0;
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||
_totalFileSize += i->second;
|
||||
|
@ -415,7 +416,8 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
|||
unsigned int result = 0;
|
||||
|
||||
ThreadExecutor *threadExecutor = static_cast<ThreadExecutor*>(args);
|
||||
std::map<std::string, std::size_t>::const_iterator &it = threadExecutor->_itNextFile;
|
||||
std::map<std::string, std::size_t>::const_iterator &itFile = threadExecutor->_itNextFile;
|
||||
std::list<Settings::FileSettings>::const_iterator &itFileSettings = threadExecutor->_itNextFileSettings;
|
||||
|
||||
// guard static members of CppCheck against concurrent access
|
||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
||||
|
@ -424,14 +426,16 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
|||
fileChecker.settings() = threadExecutor->_settings;
|
||||
|
||||
for (;;) {
|
||||
if (it == threadExecutor->_files.end()) {
|
||||
if (itFile == threadExecutor->_files.end() && itFileSettings == threadExecutor->_settings.fileSettings.end()) {
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
break;
|
||||
|
||||
}
|
||||
const std::string &file = it->first;
|
||||
const std::size_t fileSize = it->second;
|
||||
++it;
|
||||
|
||||
std::size_t fileSize = 0;
|
||||
if (itFile != threadExecutor->_files.end()) {
|
||||
const std::string &file = itFile->first;
|
||||
fileSize = itFile->second;
|
||||
++itFile;
|
||||
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
|
||||
|
@ -443,6 +447,12 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
|||
// Read file from a file
|
||||
result += fileChecker.check(file);
|
||||
}
|
||||
} else { // file settings..
|
||||
const Settings::FileSettings &fs = *itFileSettings;
|
||||
++itFileSettings;
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
result += fileChecker.check(fs);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include "errorlogger.h"
|
||||
#include "settings.h" // Settings::FileSettings
|
||||
|
||||
#if (defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__)
|
||||
#define THREADING_MODEL_FORK
|
||||
|
@ -109,6 +110,7 @@ private:
|
|||
|
||||
std::map<std::string, std::string> _fileContents;
|
||||
std::map<std::string, std::size_t>::const_iterator _itNextFile;
|
||||
std::list<Settings::FileSettings>::const_iterator _itNextFileSettings;
|
||||
std::size_t _processedFiles;
|
||||
std::size_t _totalFiles;
|
||||
std::size_t _processedSize;
|
||||
|
|
Loading…
Reference in New Issue