From 4bb62fc8b2f45d136cbfce07c95f1225768526f9 Mon Sep 17 00:00:00 2001 From: Gerhard Zlabinger Date: Thu, 13 Dec 2012 18:47:13 +0100 Subject: [PATCH] CLI: write status messages --- cli/threadexecutor.cpp | 23 ++++++++++++++++++++++- cli/threadexecutor.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 7bb79d13a..11a60530b 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -317,6 +317,14 @@ unsigned int ThreadExecutor::check() _itNextFile = _files.begin(); + _processedFiles = 0; + _processedSize = 0; + _totalFiles = _files.size(); + _totalFileSize = 0; + for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { + _totalFileSize += i->second; + } + InitializeCriticalSection(&_fileSync); InitializeCriticalSection(&_errorSync); InitializeCriticalSection(&_reportSync); @@ -390,7 +398,9 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args) return result; } - const std::string &file = (it++)->first; + const std::string &file = it->first; + const int fileSize = it->second; + it++; LeaveCriticalSection(&threadExecutor->_fileSync); @@ -402,6 +412,17 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args) result += fileChecker.check(file); } + EnterCriticalSection(&threadExecutor->_fileSync); + + threadExecutor->_processedSize += fileSize; + threadExecutor->_processedFiles++; + if (!threadExecutor->_settings._errorsOnly) { + EnterCriticalSection(&threadExecutor->_reportSync); + CppCheckExecutor::reportStatus(threadExecutor->_processedFiles, threadExecutor->_totalFiles, threadExecutor->_processedSize, threadExecutor->_totalFileSize); + LeaveCriticalSection(&threadExecutor->_reportSync); + } + + LeaveCriticalSection(&threadExecutor->_fileSync); }; return result; diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index 283be6f64..9a6e61dfc 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -102,6 +102,10 @@ private: std::map _fileContents; std::map::const_iterator _itNextFile; + unsigned int _processedFiles; + unsigned int _totalFiles; + size_t _processedSize; + size_t _totalFileSize; CRITICAL_SECTION _fileSync; std::list _errorList;