Rename variables in threadexecutor according to our naming convention
This commit is contained in:
parent
96a1c6dec5
commit
8198bd5e8f
|
@ -50,16 +50,16 @@
|
||||||
using std::memset;
|
using std::memset;
|
||||||
|
|
||||||
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
||||||
: _files(files), _settings(settings), _errorLogger(errorLogger), _fileCount(0)
|
: mFiles(files), mSettings(settings), mErrorLogger(errorLogger), mFileCount(0)
|
||||||
// Not initialized _fileSync, _errorSync, _reportSync
|
// Not initialized mFileSync, mErrorSync, mReportSync
|
||||||
{
|
{
|
||||||
#if defined(THREADING_MODEL_FORK)
|
#if defined(THREADING_MODEL_FORK)
|
||||||
_wpipe = 0;
|
mWpipe = 0;
|
||||||
#elif defined(THREADING_MODEL_WIN)
|
#elif defined(THREADING_MODEL_WIN)
|
||||||
_processedFiles = 0;
|
mProcessedFiles = 0;
|
||||||
_totalFiles = 0;
|
mTotalFiles = 0;
|
||||||
_processedSize = 0;
|
mProcessedSize = 0;
|
||||||
_totalFileSize = 0;
|
mTotalFileSize = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ ThreadExecutor::~ThreadExecutor()
|
||||||
|
|
||||||
void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
|
void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
|
||||||
{
|
{
|
||||||
_fileContents[ path ] = content;
|
mFileContents[ path ] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
|
int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
|
||||||
|
@ -112,20 +112,20 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
|
||||||
buf[readIntoBuf] = 0;
|
buf[readIntoBuf] = 0;
|
||||||
|
|
||||||
if (type == REPORT_OUT) {
|
if (type == REPORT_OUT) {
|
||||||
_errorLogger.reportOut(buf);
|
mErrorLogger.reportOut(buf);
|
||||||
} else if (type == REPORT_ERROR || type == REPORT_INFO) {
|
} else if (type == REPORT_ERROR || type == REPORT_INFO) {
|
||||||
ErrorLogger::ErrorMessage msg;
|
ErrorLogger::ErrorMessage msg;
|
||||||
msg.deserialize(buf);
|
msg.deserialize(buf);
|
||||||
|
|
||||||
if (!_settings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage())) {
|
if (!mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage())) {
|
||||||
// Alert only about unique errors
|
// Alert only about unique errors
|
||||||
std::string errmsg = msg.toString(_settings.verbose);
|
std::string errmsg = msg.toString(mSettings.verbose);
|
||||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {
|
if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) == mErrorList.end()) {
|
||||||
_errorList.push_back(errmsg);
|
mErrorList.push_back(errmsg);
|
||||||
if (type == REPORT_ERROR)
|
if (type == REPORT_ERROR)
|
||||||
_errorLogger.reportErr(msg);
|
mErrorLogger.reportErr(msg);
|
||||||
else
|
else
|
||||||
_errorLogger.reportInfo(msg);
|
mErrorLogger.reportInfo(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == CHILD_END) {
|
} else if (type == CHILD_END) {
|
||||||
|
@ -146,7 +146,7 @@ bool ThreadExecutor::checkLoadAverage(size_t nchildren)
|
||||||
#if defined(__CYGWIN__) || defined(__QNX__) // getloadavg() is unsupported on Cygwin, Qnx.
|
#if defined(__CYGWIN__) || defined(__QNX__) // getloadavg() is unsupported on Cygwin, Qnx.
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
if (!nchildren || !_settings.loadAverage) {
|
if (!nchildren || !mSettings.loadAverage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ bool ThreadExecutor::checkLoadAverage(size_t nchildren)
|
||||||
if (getloadavg(&sample, 1) != 1) {
|
if (getloadavg(&sample, 1) != 1) {
|
||||||
// disable load average checking on getloadavg error
|
// disable load average checking on getloadavg error
|
||||||
return true;
|
return true;
|
||||||
} else if (sample < _settings.loadAverage) {
|
} else if (sample < mSettings.loadAverage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -163,11 +163,11 @@ bool ThreadExecutor::checkLoadAverage(size_t nchildren)
|
||||||
|
|
||||||
unsigned int ThreadExecutor::check()
|
unsigned int ThreadExecutor::check()
|
||||||
{
|
{
|
||||||
_fileCount = 0;
|
mFileCount = 0;
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
|
|
||||||
std::size_t totalfilesize = 0;
|
std::size_t totalfilesize = 0;
|
||||||
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i) {
|
||||||
totalfilesize += i->second;
|
totalfilesize += i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,12 +175,12 @@ unsigned int ThreadExecutor::check()
|
||||||
std::map<pid_t, std::string> childFile;
|
std::map<pid_t, std::string> childFile;
|
||||||
std::map<int, std::string> pipeFile;
|
std::map<int, std::string> pipeFile;
|
||||||
std::size_t processedsize = 0;
|
std::size_t processedsize = 0;
|
||||||
std::map<std::string, std::size_t>::const_iterator iFile = _files.begin();
|
std::map<std::string, std::size_t>::const_iterator iFile = mFiles.begin();
|
||||||
std::list<ImportProject::FileSettings>::const_iterator iFileSettings = _settings.project.fileSettings.begin();
|
std::list<ImportProject::FileSettings>::const_iterator iFileSettings = mSettings.project.fileSettings.begin();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Start a new child
|
// Start a new child
|
||||||
size_t nchildren = rpipes.size();
|
size_t nchildren = rpipes.size();
|
||||||
if ((iFile != _files.end() || iFileSettings != _settings.project.fileSettings.end()) && nchildren < _settings.jobs && checkLoadAverage(nchildren)) {
|
if ((iFile != mFiles.end() || iFileSettings != mSettings.project.fileSettings.end()) && nchildren < mSettings.jobs && checkLoadAverage(nchildren)) {
|
||||||
int pipes[2];
|
int pipes[2];
|
||||||
if (pipe(pipes) == -1) {
|
if (pipe(pipes) == -1) {
|
||||||
std::cerr << "#### ThreadExecutor::check, pipe() failed: "<< std::strerror(errno) << std::endl;
|
std::cerr << "#### ThreadExecutor::check, pipe() failed: "<< std::strerror(errno) << std::endl;
|
||||||
|
@ -205,17 +205,17 @@ unsigned int ThreadExecutor::check()
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
close(pipes[0]);
|
close(pipes[0]);
|
||||||
_wpipe = pipes[1];
|
mWpipe = pipes[1];
|
||||||
|
|
||||||
CppCheck fileChecker(*this, false);
|
CppCheck fileChecker(*this, false);
|
||||||
fileChecker.settings() = _settings;
|
fileChecker.settings() = mSettings;
|
||||||
unsigned int resultOfCheck = 0;
|
unsigned int resultOfCheck = 0;
|
||||||
|
|
||||||
if (iFileSettings != _settings.project.fileSettings.end()) {
|
if (iFileSettings != mSettings.project.fileSettings.end()) {
|
||||||
resultOfCheck = fileChecker.check(*iFileSettings);
|
resultOfCheck = fileChecker.check(*iFileSettings);
|
||||||
} else if (!_fileContents.empty() && _fileContents.find(iFile->first) != _fileContents.end()) {
|
} else if (!mFileContents.empty() && mFileContents.find(iFile->first) != mFileContents.end()) {
|
||||||
// File content was given as a string
|
// File content was given as a string
|
||||||
resultOfCheck = fileChecker.check(iFile->first, _fileContents[ iFile->first ]);
|
resultOfCheck = fileChecker.check(iFile->first, mFileContents[ iFile->first ]);
|
||||||
} else {
|
} else {
|
||||||
// Read file from a file
|
// Read file from a file
|
||||||
resultOfCheck = fileChecker.check(iFile->first);
|
resultOfCheck = fileChecker.check(iFile->first);
|
||||||
|
@ -229,7 +229,7 @@ unsigned int ThreadExecutor::check()
|
||||||
|
|
||||||
close(pipes[1]);
|
close(pipes[1]);
|
||||||
rpipes.push_back(pipes[0]);
|
rpipes.push_back(pipes[0]);
|
||||||
if (iFileSettings != _settings.project.fileSettings.end()) {
|
if (iFileSettings != mSettings.project.fileSettings.end()) {
|
||||||
childFile[pid] = iFileSettings->filename + ' ' + iFileSettings->cfg;
|
childFile[pid] = iFileSettings->filename + ' ' + iFileSettings->cfg;
|
||||||
pipeFile[pipes[0]] = iFileSettings->filename + ' ' + iFileSettings->cfg;
|
pipeFile[pipes[0]] = iFileSettings->filename + ' ' + iFileSettings->cfg;
|
||||||
++iFileSettings;
|
++iFileSettings;
|
||||||
|
@ -259,16 +259,16 @@ unsigned int ThreadExecutor::check()
|
||||||
if (p != pipeFile.end()) {
|
if (p != pipeFile.end()) {
|
||||||
std::string name = p->second;
|
std::string name = p->second;
|
||||||
pipeFile.erase(p);
|
pipeFile.erase(p);
|
||||||
std::map<std::string, std::size_t>::const_iterator fs = _files.find(name);
|
std::map<std::string, std::size_t>::const_iterator fs = mFiles.find(name);
|
||||||
if (fs != _files.end()) {
|
if (fs != mFiles.end()) {
|
||||||
size = fs->second;
|
size = fs->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileCount++;
|
mFileCount++;
|
||||||
processedsize += size;
|
processedsize += size;
|
||||||
if (!_settings.quiet)
|
if (!mSettings.quiet)
|
||||||
CppCheckExecutor::reportStatus(_fileCount, _files.size() + _settings.project.fileSettings.size(), processedsize, totalfilesize);
|
CppCheckExecutor::reportStatus(mFileCount, mFiles.size() + mSettings.project.fileSettings.size(), processedsize, totalfilesize);
|
||||||
|
|
||||||
close(*rp);
|
close(*rp);
|
||||||
rp = rpipes.erase(rp);
|
rp = rpipes.erase(rp);
|
||||||
|
@ -302,8 +302,8 @@ unsigned int ThreadExecutor::check()
|
||||||
"cppcheckError",
|
"cppcheckError",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
if (!_settings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
|
if (!mSettings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
|
||||||
_errorLogger.reportErr(errmsg);
|
mErrorLogger.reportErr(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -323,7 +323,7 @@ void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data)
|
||||||
out[0] = static_cast<char>(type);
|
out[0] = static_cast<char>(type);
|
||||||
std::memcpy(&(out[1]), &len, sizeof(len));
|
std::memcpy(&(out[1]), &len, sizeof(len));
|
||||||
std::memcpy(&(out[1+sizeof(len)]), data.c_str(), len);
|
std::memcpy(&(out[1+sizeof(len)]), data.c_str(), len);
|
||||||
if (write(_wpipe, out, len + 1 + sizeof(len)) <= 0) {
|
if (write(mWpipe, out, len + 1 + sizeof(len)) <= 0) {
|
||||||
delete [] out;
|
delete [] out;
|
||||||
out = nullptr;
|
out = nullptr;
|
||||||
std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
|
std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
|
||||||
|
@ -352,29 +352,29 @@ void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||||
|
|
||||||
void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
|
void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
|
||||||
{
|
{
|
||||||
_fileContents[path] = content;
|
mFileContents[path] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ThreadExecutor::check()
|
unsigned int ThreadExecutor::check()
|
||||||
{
|
{
|
||||||
HANDLE *threadHandles = new HANDLE[_settings.jobs];
|
HANDLE *threadHandles = new HANDLE[mSettings.jobs];
|
||||||
|
|
||||||
_itNextFile = _files.begin();
|
mItNextFile = mFiles.begin();
|
||||||
_itNextFileSettings = _settings.project.fileSettings.begin();
|
mItNextFileSettings = mSettings.project.fileSettings.begin();
|
||||||
|
|
||||||
_processedFiles = 0;
|
mProcessedFiles = 0;
|
||||||
_processedSize = 0;
|
mProcessedSize = 0;
|
||||||
_totalFiles = _files.size() + _settings.project.fileSettings.size();
|
mTotalFiles = mFiles.size() + mSettings.project.fileSettings.size();
|
||||||
_totalFileSize = 0;
|
mTotalFileSize = 0;
|
||||||
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i) {
|
||||||
_totalFileSize += i->second;
|
mTotalFileSize += i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSection(&_fileSync);
|
InitializeCriticalSection(&mFileSync);
|
||||||
InitializeCriticalSection(&_errorSync);
|
InitializeCriticalSection(&mErrorSync);
|
||||||
InitializeCriticalSection(&_reportSync);
|
InitializeCriticalSection(&mReportSync);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < _settings.jobs; ++i) {
|
for (unsigned int i = 0; i < mSettings.jobs; ++i) {
|
||||||
threadHandles[i] = (HANDLE)_beginthreadex(nullptr, 0, threadProc, this, 0, nullptr);
|
threadHandles[i] = (HANDLE)_beginthreadex(nullptr, 0, threadProc, this, 0, nullptr);
|
||||||
if (!threadHandles[i]) {
|
if (!threadHandles[i]) {
|
||||||
std::cerr << "#### ThreadExecutor::check error, errno :" << errno << std::endl;
|
std::cerr << "#### ThreadExecutor::check error, errno :" << errno << std::endl;
|
||||||
|
@ -382,7 +382,7 @@ unsigned int ThreadExecutor::check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWORD waitResult = WaitForMultipleObjects(_settings.jobs, threadHandles, TRUE, INFINITE);
|
const DWORD waitResult = WaitForMultipleObjects(mSettings.jobs, threadHandles, TRUE, INFINITE);
|
||||||
if (waitResult != WAIT_OBJECT_0) {
|
if (waitResult != WAIT_OBJECT_0) {
|
||||||
if (waitResult == WAIT_FAILED) {
|
if (waitResult == WAIT_FAILED) {
|
||||||
std::cerr << "#### ThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
|
std::cerr << "#### ThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
|
||||||
|
@ -394,7 +394,7 @@ unsigned int ThreadExecutor::check()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
for (unsigned int i = 0; i < _settings.jobs; ++i) {
|
for (unsigned int i = 0; i < mSettings.jobs; ++i) {
|
||||||
DWORD exitCode;
|
DWORD exitCode;
|
||||||
|
|
||||||
if (!GetExitCodeThread(threadHandles[i], &exitCode)) {
|
if (!GetExitCodeThread(threadHandles[i], &exitCode)) {
|
||||||
|
@ -410,9 +410,9 @@ unsigned int ThreadExecutor::check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCriticalSection(&_fileSync);
|
DeleteCriticalSection(&mFileSync);
|
||||||
DeleteCriticalSection(&_errorSync);
|
DeleteCriticalSection(&mErrorSync);
|
||||||
DeleteCriticalSection(&_reportSync);
|
DeleteCriticalSection(&mReportSync);
|
||||||
|
|
||||||
delete[] threadHandles;
|
delete[] threadHandles;
|
||||||
|
|
||||||
|
@ -424,31 +424,31 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
|
|
||||||
ThreadExecutor *threadExecutor = static_cast<ThreadExecutor*>(args);
|
ThreadExecutor *threadExecutor = static_cast<ThreadExecutor*>(args);
|
||||||
std::map<std::string, std::size_t>::const_iterator &itFile = threadExecutor->_itNextFile;
|
std::map<std::string, std::size_t>::const_iterator &itFile = threadExecutor->mItNextFile;
|
||||||
std::list<ImportProject::FileSettings>::const_iterator &itFileSettings = threadExecutor->_itNextFileSettings;
|
std::list<ImportProject::FileSettings>::const_iterator &itFileSettings = threadExecutor->mItNextFileSettings;
|
||||||
|
|
||||||
// guard static members of CppCheck against concurrent access
|
// guard static members of CppCheck against concurrent access
|
||||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
EnterCriticalSection(&threadExecutor->mFileSync);
|
||||||
|
|
||||||
CppCheck fileChecker(*threadExecutor, false);
|
CppCheck fileChecker(*threadExecutor, false);
|
||||||
fileChecker.settings() = threadExecutor->_settings;
|
fileChecker.settings() = threadExecutor->mSettings;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (itFile == threadExecutor->_files.end() && itFileSettings == threadExecutor->_settings.project.fileSettings.end()) {
|
if (itFile == threadExecutor->mFiles.end() && itFileSettings == threadExecutor->mSettings.project.fileSettings.end()) {
|
||||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
LeaveCriticalSection(&threadExecutor->mFileSync);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t fileSize = 0;
|
std::size_t fileSize = 0;
|
||||||
if (itFile != threadExecutor->_files.end()) {
|
if (itFile != threadExecutor->mFiles.end()) {
|
||||||
const std::string &file = itFile->first;
|
const std::string &file = itFile->first;
|
||||||
fileSize = itFile->second;
|
fileSize = itFile->second;
|
||||||
++itFile;
|
++itFile;
|
||||||
|
|
||||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
LeaveCriticalSection(&threadExecutor->mFileSync);
|
||||||
|
|
||||||
const std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents.find(file);
|
const std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->mFileContents.find(file);
|
||||||
if (fileContent != threadExecutor->_fileContents.end()) {
|
if (fileContent != threadExecutor->mFileContents.end()) {
|
||||||
// File content was given as a string
|
// File content was given as a string
|
||||||
result += fileChecker.check(file, fileContent->second);
|
result += fileChecker.check(file, fileContent->second);
|
||||||
} else {
|
} else {
|
||||||
|
@ -458,18 +458,18 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
||||||
} else { // file settings..
|
} else { // file settings..
|
||||||
const ImportProject::FileSettings &fs = *itFileSettings;
|
const ImportProject::FileSettings &fs = *itFileSettings;
|
||||||
++itFileSettings;
|
++itFileSettings;
|
||||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
LeaveCriticalSection(&threadExecutor->mFileSync);
|
||||||
result += fileChecker.check(fs);
|
result += fileChecker.check(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
EnterCriticalSection(&threadExecutor->mFileSync);
|
||||||
|
|
||||||
threadExecutor->_processedSize += fileSize;
|
threadExecutor->mProcessedSize += fileSize;
|
||||||
threadExecutor->_processedFiles++;
|
threadExecutor->mProcessedFiles++;
|
||||||
if (!threadExecutor->_settings.quiet) {
|
if (!threadExecutor->mSettings.quiet) {
|
||||||
EnterCriticalSection(&threadExecutor->_reportSync);
|
EnterCriticalSection(&threadExecutor->mReportSync);
|
||||||
CppCheckExecutor::reportStatus(threadExecutor->_processedFiles, threadExecutor->_totalFiles, threadExecutor->_processedSize, threadExecutor->_totalFileSize);
|
CppCheckExecutor::reportStatus(threadExecutor->mProcessedFiles, threadExecutor->mTotalFiles, threadExecutor->mProcessedSize, threadExecutor->mTotalFileSize);
|
||||||
LeaveCriticalSection(&threadExecutor->_reportSync);
|
LeaveCriticalSection(&threadExecutor->mReportSync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -477,11 +477,11 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
||||||
|
|
||||||
void ThreadExecutor::reportOut(const std::string &outmsg)
|
void ThreadExecutor::reportOut(const std::string &outmsg)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&_reportSync);
|
EnterCriticalSection(&mReportSync);
|
||||||
|
|
||||||
_errorLogger.reportOut(outmsg);
|
mErrorLogger.reportOut(outmsg);
|
||||||
|
|
||||||
LeaveCriticalSection(&_reportSync);
|
LeaveCriticalSection(&mReportSync);
|
||||||
}
|
}
|
||||||
void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
|
void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||||
{
|
{
|
||||||
|
@ -495,33 +495,33 @@ void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||||
|
|
||||||
void ThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType msgType)
|
void ThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType msgType)
|
||||||
{
|
{
|
||||||
if (_settings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
|
if (mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Alert only about unique errors
|
// Alert only about unique errors
|
||||||
bool reportError = false;
|
bool reportError = false;
|
||||||
const std::string errmsg = msg.toString(_settings.verbose);
|
const std::string errmsg = msg.toString(mSettings.verbose);
|
||||||
|
|
||||||
EnterCriticalSection(&_errorSync);
|
EnterCriticalSection(&mErrorSync);
|
||||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {
|
if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) == mErrorList.end()) {
|
||||||
_errorList.push_back(errmsg);
|
mErrorList.push_back(errmsg);
|
||||||
reportError = true;
|
reportError = true;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&_errorSync);
|
LeaveCriticalSection(&mErrorSync);
|
||||||
|
|
||||||
if (reportError) {
|
if (reportError) {
|
||||||
EnterCriticalSection(&_reportSync);
|
EnterCriticalSection(&mReportSync);
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case REPORT_ERROR:
|
case REPORT_ERROR:
|
||||||
_errorLogger.reportErr(msg);
|
mErrorLogger.reportErr(msg);
|
||||||
break;
|
break;
|
||||||
case REPORT_INFO:
|
case REPORT_INFO:
|
||||||
_errorLogger.reportInfo(msg);
|
mErrorLogger.reportInfo(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&_reportSync);
|
LeaveCriticalSection(&mReportSync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ class Settings;
|
||||||
class ThreadExecutor : public ErrorLogger {
|
class ThreadExecutor : public ErrorLogger {
|
||||||
public:
|
public:
|
||||||
ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
||||||
|
ThreadExecutor(const ThreadExecutor &) = delete;
|
||||||
virtual ~ThreadExecutor();
|
virtual ~ThreadExecutor();
|
||||||
|
void operator=(const ThreadExecutor &) = delete;
|
||||||
unsigned int check();
|
unsigned int check();
|
||||||
|
|
||||||
virtual void reportOut(const std::string &outmsg) OVERRIDE;
|
virtual void reportOut(const std::string &outmsg) OVERRIDE;
|
||||||
|
@ -63,15 +65,15 @@ public:
|
||||||
void addFileContent(const std::string &path, const std::string &content);
|
void addFileContent(const std::string &path, const std::string &content);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::map<std::string, std::size_t> &_files;
|
const std::map<std::string, std::size_t> &mFiles;
|
||||||
Settings &_settings;
|
Settings &mSettings;
|
||||||
ErrorLogger &_errorLogger;
|
ErrorLogger &mErrorLogger;
|
||||||
unsigned int _fileCount;
|
unsigned int mFileCount;
|
||||||
|
|
||||||
#if defined(THREADING_MODEL_FORK)
|
#if defined(THREADING_MODEL_FORK)
|
||||||
|
|
||||||
/** @brief Key is file name, and value is the content of the file */
|
/** @brief Key is file name, and value is the content of the file */
|
||||||
std::map<std::string, std::string> _fileContents;
|
std::map<std::string, std::string> mFileContents;
|
||||||
private:
|
private:
|
||||||
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_INFO='3', CHILD_END='4'};
|
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_INFO='3', CHILD_END='4'};
|
||||||
|
|
||||||
|
@ -87,8 +89,8 @@ private:
|
||||||
* Write end of status pipe, different for each child.
|
* Write end of status pipe, different for each child.
|
||||||
* Not used in master process.
|
* Not used in master process.
|
||||||
*/
|
*/
|
||||||
std::list<std::string> _errorList;
|
std::list<std::string> mErrorList;
|
||||||
int _wpipe;
|
int mWpipe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check load average condition
|
* @brief Check load average condition
|
||||||
|
@ -110,19 +112,19 @@ public:
|
||||||
private:
|
private:
|
||||||
enum MessageType {REPORT_ERROR, REPORT_INFO};
|
enum MessageType {REPORT_ERROR, REPORT_INFO};
|
||||||
|
|
||||||
std::map<std::string, std::string> _fileContents;
|
std::map<std::string, std::string> mFileContents;
|
||||||
std::map<std::string, std::size_t>::const_iterator _itNextFile;
|
std::map<std::string, std::size_t>::const_iterator mItNextFile;
|
||||||
std::list<ImportProject::FileSettings>::const_iterator _itNextFileSettings;
|
std::list<ImportProject::FileSettings>::const_iterator mItNextFileSettings;
|
||||||
std::size_t _processedFiles;
|
std::size_t mProcessedFiles;
|
||||||
std::size_t _totalFiles;
|
std::size_t mTotalFiles;
|
||||||
std::size_t _processedSize;
|
std::size_t mProcessedSize;
|
||||||
std::size_t _totalFileSize;
|
std::size_t mTotalFileSize;
|
||||||
CRITICAL_SECTION _fileSync;
|
CRITICAL_SECTION mFileSync;
|
||||||
|
|
||||||
std::list<std::string> _errorList;
|
std::list<std::string> mErrorList;
|
||||||
CRITICAL_SECTION _errorSync;
|
CRITICAL_SECTION mErrorSync;
|
||||||
|
|
||||||
CRITICAL_SECTION _reportSync;
|
CRITICAL_SECTION mReportSync;
|
||||||
|
|
||||||
void report(const ErrorLogger::ErrorMessage &msg, MessageType msgType);
|
void report(const ErrorLogger::ErrorMessage &msg, MessageType msgType);
|
||||||
|
|
||||||
|
@ -144,13 +146,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
/** disabled copy constructor */
|
|
||||||
ThreadExecutor(const ThreadExecutor &);
|
|
||||||
|
|
||||||
/** disabled assignment operator */
|
|
||||||
void operator=(const ThreadExecutor &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
Loading…
Reference in New Issue