A thread might be shut down with the thread running
GoogleCodeExporter opened this issue · 0 comments
GoogleCodeExporter commented
This is also a minor issue. If shutting down a thread, the existing while-
loop might break out after having fetched a task off of the job queue, and
might therefore not complete the task.
I would recommend restructuring threadmain something like this - so there
is no way to break out between a job being fetched and executed.
void ThreadWorker::threadMain(void)
{
while ( !mExit )
{
SwarmJob *job = 0;
if ( !mFinished.isFull() )
{
job = mJobScheduler->getJob(); // get a
new job to perform.
}
if(!job)
{
mSwarmJob = 0;
mBusy->resetEvent();
mBusy->waitForSingleObject(10);
continue;
}
mSwarmJob = job;
if ( !job->isCancelled() )
{
job->onExecute(); // execute
the job.
}
mFinished.push(job);
}
mRunning = false;
}
Original issue reported on code.google.com by Shanni...@gmail.com
on 14 Mar 2009 at 3:58