Some minor tweaks to the multi-threaded FileAnalyzer class.
This commit is contained in:
parent
b00b527897
commit
7d36e9d82e
@ -30,7 +30,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 5
|
#define VER_LAMEXP_MINOR_LO 5
|
||||||
#define VER_LAMEXP_TYPE Alpha
|
#define VER_LAMEXP_TYPE Alpha
|
||||||
#define VER_LAMEXP_PATCH 1
|
#define VER_LAMEXP_PATCH 1
|
||||||
#define VER_LAMEXP_BUILD 998
|
#define VER_LAMEXP_BUILD 1001
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Tool versions (minimum expected versions!)
|
// Tool versions (minimum expected versions!)
|
||||||
|
@ -125,6 +125,11 @@ void FileAnalyzer::run()
|
|||||||
AnalyzeTask::reset();
|
AnalyzeTask::reset();
|
||||||
QThreadPool *pool = new QThreadPool();
|
QThreadPool *pool = new QThreadPool();
|
||||||
|
|
||||||
|
if(pool->maxThreadCount() < 2)
|
||||||
|
{
|
||||||
|
pool->setMaxThreadCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
while(!(m_inputFiles.isEmpty() || m_bAborted))
|
while(!(m_inputFiles.isEmpty() || m_bAborted))
|
||||||
{
|
{
|
||||||
while(!(m_inputFiles.isEmpty() || m_bAborted))
|
while(!(m_inputFiles.isEmpty() || m_bAborted))
|
||||||
@ -142,7 +147,7 @@ void FileAnalyzer::run()
|
|||||||
|
|
||||||
while(!pool->tryStart(task))
|
while(!pool->tryStart(task))
|
||||||
{
|
{
|
||||||
QThread::msleep(125); //No more free threads, wait for active threads!
|
pool->waitForDone(250); //No more free threads, wait for active threads!
|
||||||
if(m_abortFlag) { LAMEXP_DELETE(task); break; }
|
if(m_abortFlag) { LAMEXP_DELETE(task); break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +170,6 @@ void FileAnalyzer::run()
|
|||||||
pool->waitForDone();
|
pool->waitForDone();
|
||||||
LAMEXP_DELETE(pool);
|
LAMEXP_DELETE(pool);
|
||||||
|
|
||||||
|
|
||||||
if(m_bAborted)
|
if(m_bAborted)
|
||||||
{
|
{
|
||||||
qWarning("Operation cancelled by user!");
|
qWarning("Operation cancelled by user!");
|
||||||
|
@ -692,6 +692,9 @@ unsigned __int64 AnalyzeTask::makeThreadIdx(void)
|
|||||||
|
|
||||||
void AnalyzeTask::waitForPreviousThreads(void)
|
void AnalyzeTask::waitForPreviousThreads(void)
|
||||||
{
|
{
|
||||||
|
//This function will block until all threads with a *lower* index have terminated.
|
||||||
|
//Required to make sure that the files will be added in the "correct" order!
|
||||||
|
|
||||||
for(int i = 0; i < 240; i++)
|
for(int i = 0; i < 240; i++)
|
||||||
{
|
{
|
||||||
QReadLocker lock(&s_lock);
|
QReadLocker lock(&s_lock);
|
||||||
@ -699,8 +702,9 @@ void AnalyzeTask::waitForPreviousThreads(void)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
DWORD sleepInterval = 100 + (static_cast<DWORD>(qBound(1ui64, m_threadIdx - s_threadIdx_finished, 8ui64)) * 25);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
Sleep(125);
|
Sleep(sleepInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user