diff Core/JobsEngine/JobsRegistry.cpp @ 2976:cb5d75143da0

Asynchronous generation of ZIP archives and DICOM medias
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Dec 2018 12:23:46 +0100
parents d924f9bb61cc
children 4e43e67f8ecf
line wrap: on
line diff
--- a/Core/JobsEngine/JobsRegistry.cpp	Thu Dec 06 10:10:58 2018 +0100
+++ b/Core/JobsEngine/JobsRegistry.cpp	Thu Dec 06 12:23:46 2018 +0100
@@ -263,7 +263,7 @@
         // as a "RunningJob" instance is running. We do not use a
         // mutex at the "JobHandler" level, as serialization would be
         // blocked while a step in the job is running. Instead, we
-        // save a snapshot of the serialized job.
+        // save a snapshot of the serialized job. (*)
 
         if (lastStatus_.HasSerialized())
         {
@@ -631,6 +631,36 @@
   }
 
 
+  bool JobsRegistry::GetJobOutput(std::string& output,
+                                  MimeType& mime,
+                                  const std::string& job,
+                                  const std::string& key)
+  {
+    boost::mutex::scoped_lock lock(mutex_);
+    CheckInvariants();
+
+    JobsIndex::const_iterator found = jobsIndex_.find(job);
+
+    if (found == jobsIndex_.end())
+    {
+      return false;
+    }
+    else
+    {
+      const JobHandler& handler = *found->second;
+
+      if (handler.GetState() == JobState_Success)
+      {
+        return handler.GetJob().GetOutput(output, mime, key);
+      }
+      else
+      {
+        return false;
+      }
+    }
+  }
+
+
   void JobsRegistry::SubmitInternal(std::string& id,
                                     JobHandler* handler)
   {