Commit 47420473 authored by David COME's avatar David COME
Browse files

Use an auto_ptr to automatically handle Task destruction in DiskXXXWorkerThread::run

parent 3293bbf8
......@@ -79,11 +79,13 @@ private:
DiskReadThreadPool & m_manager;
virtual void run() {
while(1) {
DiskReadTaskInterface * task = m_manager.m_tasks.pop();
std::auto_ptr<DiskReadTaskInterface> task ( m_manager.m_tasks.pop());
bool end = task->endOfWork();
if (!end) task->execute();
delete task;
if (end) return;
if (!end)
task->execute();
else
break;
}
}
};
......
......@@ -129,13 +129,13 @@ private:
DiskWriteThreadPool & m_manager;
virtual void run() {
while(1) {
DiskWriteTaskInterface * task = m_manager.popAndRequestMoreJobs();
std::auto_ptr<DiskWriteTaskInterface> task (m_manager.popAndRequestMoreJobs());
bool end = task->endOfWork();
if (!end) task->execute();
delete task;
if (end) {
if (!end)
task->execute();
else {
printf ("Disk write thread finishing\n");
return;
break;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment