Commit 95d73d42 authored by David COME's avatar David COME
Browse files

Moved from nested endOfSession+endOfWork()==true sentinel to NULL

parent c5165263
......@@ -37,7 +37,7 @@ namespace daemon {
class DiskReadThreadPool : public DiskThreadPoolInterface<DiskReadTaskInterface> {
public:
DiskReadThreadPool(int nbThread) {
DiskReadThreadPool(int nbThread){
for(int i=0; i<nbThread; i++) {
DiskReadWorkerThread * thr = new DiskReadWorkerThread(*this);
m_threads.push_back(thr);
......@@ -65,7 +65,7 @@ public:
void finish() {
/* Insert one endOfSession per thread */
for (size_t i=0; i<m_threads.size(); i++) {
m_tasks.push(new endOfSession);
m_tasks.push(NULL);
}
}
......@@ -78,11 +78,10 @@ private:
private:
DiskReadThreadPool & m_manager;
virtual void run() {
std::auto_ptr<DiskReadTaskInterface> task;
while(1) {
std::auto_ptr<DiskReadTaskInterface> task ( m_manager.m_tasks.pop());
bool end = task->endOfWork();
if (!end)
task.reset( m_manager.m_tasks.pop());
if (NULL!=task.get())
task->execute();
else
break;
......
......@@ -78,7 +78,7 @@ public:
void finish() {
/* Insert one endOfSession per thread */
for (size_t i=0; i<m_threads.size(); i++) {
m_tasks.push(new endOfSession);
m_tasks.push(NULL);
}
}
void setJobInjector(TaskInjector * ji){
......@@ -128,10 +128,10 @@ private:
private:
DiskWriteThreadPool & m_manager;
virtual void run() {
std::auto_ptr<DiskWriteTaskInterface> task;
while(1) {
std::auto_ptr<DiskWriteTaskInterface> task (m_manager.popAndRequestMoreJobs());
bool end = task->endOfWork();
if (!end)
task.reset(m_manager.popAndRequestMoreJobs());
if (NULL!=task.get())
task->execute();
else {
printf ("Disk write thread finishing\n");
......
......@@ -19,7 +19,7 @@ public:
virtual void finish()
{
m_tasks.push(new endOfSession);
m_tasks.push(NULL);
}
virtual void push(DiskWriteTaskInterface* t){
m_tasks.push(t);
......@@ -92,9 +92,8 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
DiskWriteTaskInterface* diskWriteTask=diskWrite.m_tasks.pop();
TapeReadTask* tapeReadTask=tapeRead.m_tasks.pop();
ASSERT_EQ(diskWriteTask->endOfWork(),true);
ASSERT_EQ(tapeReadTask->endOfWork(),true);
ASSERT_EQ(NULL,diskWriteTask);
ASSERT_EQ(true,tapeReadTask->endOfWork());
delete diskWriteTask;
delete tapeReadTask;
}
......
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