diff Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp @ 2608:25225f0b4f33 jobs

simplification wrt. dicom connection manager
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 19 May 2018 15:50:09 +0200
parents 988936118354
children 2f3007bf0708
line wrap: on
line diff
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Sat May 19 15:28:41 2018 +0200
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Sat May 19 15:50:09 2018 +0200
@@ -101,7 +101,7 @@
       return currentInput_ >= originalInputs_.GetSize() + workInputs_.GetSize();
     }
 
-    void Step()
+    void Step(IDicomConnectionManager& connectionManager)
     {
       if (IsDone())
       {
@@ -120,7 +120,7 @@
       }
 
       JobOperationValues outputs;
-      operation_->Apply(outputs, *input);
+      operation_->Apply(outputs, *input, connectionManager);
 
       if (!nextOperations_.empty())
       {
@@ -175,6 +175,12 @@
     that_.trailingTimeout_ = boost::posix_time::milliseconds(timeout);
   }
 
+  
+  void SequenceOfOperationsJob::Lock::SetDicomConnectionTimeout(unsigned int timeout)
+  {
+    that_.connectionManager_.SetTimeout(timeout);
+  }
+
 
   size_t SequenceOfOperationsJob::Lock::AddOperation(IJobOperation* operation)
   {
@@ -255,6 +261,7 @@
           (*it)->SignalDone(*this);
         }
 
+        connectionManager_.Close();
         return JobStepResult::Success();
       }
       else
@@ -273,9 +280,11 @@
 
     if (current_ < operations_.size())
     {
-      operations_[current_]->Step();
+      operations_[current_]->Step(connectionManager_);
     }
 
+    connectionManager_.CheckTimeout();
+
     return JobStepResult::Continue();
   }
 
@@ -294,6 +303,13 @@
   }
 
 
+  void SequenceOfOperationsJob::ReleaseResources()
+  {
+    boost::mutex::scoped_lock lock(mutex_);
+    connectionManager_.Close();
+  }
+
+
   float SequenceOfOperationsJob::GetProgress()
   {
     boost::mutex::scoped_lock lock(mutex_);