changeset 2812:ea7aea6f6a95

improved naming of methods in IJob
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Sep 2018 16:23:40 +0200
parents 7cfc8d266f41
children 6d5b20af216f
files Core/Enumerations.h Core/JobsEngine/IJob.h Core/JobsEngine/JobsEngine.cpp Core/JobsEngine/JobsRegistry.cpp Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp Core/JobsEngine/Operations/SequenceOfOperationsJob.h Core/JobsEngine/SetOfInstancesJob.cpp Core/JobsEngine/SetOfInstancesJob.h OrthancServer/ServerJobs/ArchiveJob.cpp OrthancServer/ServerJobs/ArchiveJob.h OrthancServer/ServerJobs/DicomModalityStoreJob.cpp OrthancServer/ServerJobs/DicomModalityStoreJob.h OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp OrthancServer/ServerJobs/OrthancPeerStoreJob.h OrthancServer/ServerJobs/ResourceModificationJob.h Plugins/Engine/PluginsJob.cpp Plugins/Engine/PluginsJob.h Plugins/Include/orthanc/OrthancCPlugin.h UnitTestsSources/MultiThreadingTests.cpp
diffstat 19 files changed, 103 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Enumerations.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/Enumerations.h	Thu Sep 06 16:23:40 2018 +0200
@@ -567,13 +567,13 @@
     JobStepCode_Retry
   };
 
-  enum JobReleaseReason
+  enum JobStopReason
   {
-    JobReleaseReason_Paused,
-    JobReleaseReason_Canceled,
-    JobReleaseReason_Success,
-    JobReleaseReason_Failure,
-    JobReleaseReason_Retry
+    JobStopReason_Paused,
+    JobStopReason_Canceled,
+    JobStopReason_Success,
+    JobStopReason_Failure,
+    JobStopReason_Retry
   };
 
 
--- a/Core/JobsEngine/IJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/IJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -50,13 +50,13 @@
     // Method called once the job enters the jobs engine
     virtual void Start() = 0;
     
-    virtual JobStepResult ExecuteStep() = 0;
+    virtual JobStepResult Step() = 0;
 
     // Method called once the job is resubmitted after a failure
-    virtual void SignalResubmit() = 0;
+    virtual void Reset() = 0;
 
-    // For pausing/canceling jobs
-    virtual void ReleaseResources(JobReleaseReason reason) = 0;
+    // For pausing/canceling/ending jobs: This method must release allocated resources
+    virtual void Stop(JobStopReason reason) = 0;
 
     virtual float GetProgress() = 0;
 
--- a/Core/JobsEngine/JobsEngine.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/JobsEngine.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -55,14 +55,14 @@
 
     if (running.IsPauseScheduled())
     {
-      running.GetJob().ReleaseResources(JobReleaseReason_Paused);
+      running.GetJob().Stop(JobStopReason_Paused);
       running.MarkPause();
       return false;
     }
 
     if (running.IsCancelScheduled())
     {
-      running.GetJob().ReleaseResources(JobReleaseReason_Canceled);
+      running.GetJob().Stop(JobStopReason_Canceled);
       running.MarkCanceled();
       return false;
     }
@@ -71,7 +71,7 @@
 
     try
     {
-      result = running.GetJob().ExecuteStep();
+      result = running.GetJob().Step();
     }
     catch (OrthancException& e)
     {
@@ -89,19 +89,19 @@
     switch (result.GetCode())
     {
       case JobStepCode_Success:
-        running.GetJob().ReleaseResources(JobReleaseReason_Success);
+        running.GetJob().Stop(JobStopReason_Success);
         running.UpdateStatus(ErrorCode_Success);
         running.MarkSuccess();
         return false;
 
       case JobStepCode_Failure:
-        running.GetJob().ReleaseResources(JobReleaseReason_Failure);
+        running.GetJob().Stop(JobStopReason_Failure);
         running.UpdateStatus(result.GetFailureCode());
         running.MarkFailure();
         return false;
 
       case JobStepCode_Retry:
-        running.GetJob().ReleaseResources(JobReleaseReason_Retry);
+        running.GetJob().Stop(JobStopReason_Retry);
         running.UpdateStatus(ErrorCode_Success);
         running.MarkRetry(result.GetRetryTimeout());
         return false;
--- a/Core/JobsEngine/JobsRegistry.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/JobsRegistry.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -930,7 +930,7 @@
     }
     else
     {
-      found->second->GetJob().SignalResubmit();
+      found->second->GetJob().Reset();
       
       bool ok = false;
       for (CompletedJobs::iterator it = completedJobs_.begin(); 
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -319,7 +319,7 @@
   }
 
 
-  JobStepResult SequenceOfOperationsJob::ExecuteStep()
+  JobStepResult SequenceOfOperationsJob::Step()
   {
     boost::mutex::scoped_lock lock(mutex_);
 
@@ -369,7 +369,7 @@
   }
 
 
-  void SequenceOfOperationsJob::SignalResubmit()
+  void SequenceOfOperationsJob::Reset()
   {
     boost::mutex::scoped_lock lock(mutex_);
       
@@ -383,7 +383,7 @@
   }
 
 
-  void SequenceOfOperationsJob::ReleaseResources(JobReleaseReason reason)
+  void SequenceOfOperationsJob::Stop(JobStopReason reason)
   {
     boost::mutex::scoped_lock lock(mutex_);
     connectionManager_.Close();
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -128,11 +128,11 @@
     {
     }
 
-    virtual JobStepResult ExecuteStep();
+    virtual JobStepResult Step();
 
-    virtual void SignalResubmit();
+    virtual void Reset();
 
-    virtual void ReleaseResources(JobReleaseReason reason);
+    virtual void Stop(JobStopReason reason);
 
     virtual float GetProgress();
 
--- a/Core/JobsEngine/SetOfInstancesJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/SetOfInstancesJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -86,7 +86,7 @@
   }
 
 
-  void SetOfInstancesJob::SignalResubmit()
+  void SetOfInstancesJob::Reset()
   {
     if (started_)
     {
@@ -127,7 +127,7 @@
   }
       
 
-  JobStepResult SetOfInstancesJob::ExecuteStep()
+  JobStepResult SetOfInstancesJob::Step()
   {
     if (!started_)
     {
--- a/Core/JobsEngine/SetOfInstancesJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Core/JobsEngine/SetOfInstancesJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -88,7 +88,7 @@
 
     void SetPermissive(bool permissive);
 
-    virtual void SignalResubmit();
+    virtual void Reset();
     
     virtual void Start()
     {
@@ -114,7 +114,7 @@
       return failedInstances_.find(instance) != failedInstances_.end();
     }
     
-    virtual JobStepResult ExecuteStep();
+    virtual JobStepResult Step();
     
     virtual void GetPublicContent(Json::Value& value);
     
--- a/OrthancServer/ServerJobs/ArchiveJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/ArchiveJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -810,7 +810,7 @@
   }
 
   
-  void ArchiveJob::SignalResubmit()
+  void ArchiveJob::Reset()
   {
     LOG(ERROR) << "Cannot resubmit the creation of an archive";
     throw OrthancException(ErrorCode_BadSequenceOfCalls);
@@ -832,7 +832,7 @@
   }
 
   
-  JobStepResult ArchiveJob::ExecuteStep()
+  JobStepResult ArchiveJob::Step()
   {
     assert(writer_.get() != NULL);
 
--- a/OrthancServer/ServerJobs/ArchiveJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/ArchiveJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -80,13 +80,13 @@
 
     void AddResource(const std::string& publicId);
 
-    virtual void SignalResubmit();
+    virtual void Reset();
 
     virtual void Start();
 
-    virtual JobStepResult ExecuteStep();
+    virtual JobStepResult Step();
 
-    virtual void ReleaseResources(JobReleaseReason reason)
+    virtual void Stop(JobStopReason reason)
     {
     }
 
--- a/OrthancServer/ServerJobs/DicomModalityStoreJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/DicomModalityStoreJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -164,7 +164,7 @@
     }
   }
 
-  void DicomModalityStoreJob::ReleaseResources(JobReleaseReason reason)   // For pausing jobs
+  void DicomModalityStoreJob::Stop(JobStopReason reason)   // For pausing jobs
   {
     connection_.reset(NULL);
   }
--- a/OrthancServer/ServerJobs/DicomModalityStoreJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/DicomModalityStoreJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -87,7 +87,7 @@
     void SetMoveOriginator(const std::string& aet,
                            int id);
 
-    virtual void ReleaseResources(JobReleaseReason reason);
+    virtual void Stop(JobStopReason reason);
 
     virtual void GetJobType(std::string& target)
     {
--- a/OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -87,7 +87,7 @@
   }
 
 
-  void OrthancPeerStoreJob::ReleaseResources(JobReleaseReason reason)   // For pausing jobs
+  void OrthancPeerStoreJob::Stop(JobStopReason reason)   // For pausing jobs
   {
     client_.reset(NULL);
   }
--- a/OrthancServer/ServerJobs/OrthancPeerStoreJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/OrthancPeerStoreJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -67,7 +67,7 @@
       return peer_;
     }
 
-    virtual void ReleaseResources(JobReleaseReason reason);   // For pausing jobs
+    virtual void Stop(JobStopReason reason);   // For pausing jobs
 
     virtual void GetJobType(std::string& target)
     {
--- a/OrthancServer/ServerJobs/ResourceModificationJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/OrthancServer/ServerJobs/ResourceModificationJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -106,7 +106,7 @@
       return origin_;
     }
 
-    virtual void ReleaseResources(JobReleaseReason reason)
+    virtual void Stop(JobStopReason reason)
     {
     }
 
--- a/Plugins/Engine/PluginsJob.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/Plugins/Engine/PluginsJob.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -51,7 +51,7 @@
     free_(parameters.free_),
     getProgress_(parameters.getProgress_),
     step_(parameters.step_),
-    releaseResources_(parameters.releaseResources_),
+    stop_(parameters.stop_),
     reset_(parameters.reset_)
   {
     if (job_ == NULL ||
@@ -59,7 +59,7 @@
         free_ == NULL ||
         getProgress_ == NULL ||
         step_ == NULL ||
-        releaseResources_ == NULL ||
+        stop_ == NULL ||
         reset_ == NULL)
     {
       throw OrthancException(ErrorCode_NullPointer);
@@ -108,7 +108,7 @@
     free_(job_);
   }
 
-  JobStepResult PluginsJob::ExecuteStep()
+  JobStepResult PluginsJob::Step()
   {
     OrthancPluginJobStepStatus status = step_(job_);
 
@@ -128,29 +128,29 @@
     }
   }
 
-  void PluginsJob::SignalResubmit()
+  void PluginsJob::Reset()
   {
     reset_(job_);
   }
 
-  void PluginsJob::ReleaseResources(JobReleaseReason reason)
+  void PluginsJob::Stop(JobStopReason reason)
   {
     switch (reason)
     {
-      case JobReleaseReason_Success:
-        releaseResources_(job_, OrthancPluginJobReleaseReason_Success);
+      case JobStopReason_Success:
+        stop_(job_, OrthancPluginJobStopReason_Success);
         break;
 
-      case JobReleaseReason_Failure:
-        releaseResources_(job_, OrthancPluginJobReleaseReason_Failure);
+      case JobStopReason_Failure:
+        stop_(job_, OrthancPluginJobStopReason_Failure);
         break;
 
-      case JobReleaseReason_Canceled:
-        releaseResources_(job_, OrthancPluginJobReleaseReason_Canceled);
+      case JobStopReason_Canceled:
+        stop_(job_, OrthancPluginJobStopReason_Canceled);
         break;
 
-      case JobReleaseReason_Paused:
-        releaseResources_(job_, OrthancPluginJobReleaseReason_Paused);
+      case JobStopReason_Paused:
+        stop_(job_, OrthancPluginJobStopReason_Paused);
         break;
 
       default:
--- a/Plugins/Engine/PluginsJob.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Plugins/Engine/PluginsJob.h	Thu Sep 06 16:23:40 2018 +0200
@@ -43,16 +43,16 @@
   class PluginsJob : public IJob
   {
   private:
-    void                             *job_;
-    std::string                       type_;
-    Json::Value                       publicContent_;
-    bool                              hasSerialized_;
-    Json::Value                       serialized_;
-    OrthancPluginJobFree              free_;
-    OrthancPluginJobGetProgress       getProgress_;
-    OrthancPluginJobStep              step_;
-    OrthancPluginJobReleaseResources  releaseResources_;
-    OrthancPluginJobReset             reset_;
+    void                        *job_;
+    std::string                  type_;
+    Json::Value                  publicContent_;
+    bool                         hasSerialized_;
+    Json::Value                  serialized_;
+    OrthancPluginJobFree         free_;
+    OrthancPluginJobGetProgress  getProgress_;
+    OrthancPluginJobStep         step_;
+    OrthancPluginJobStop         stop_;
+    OrthancPluginJobReset        reset_;
 
   public:
     PluginsJob(const _OrthancPluginSubmitJob& parameters);
@@ -63,11 +63,11 @@
     {
     }
     
-    virtual JobStepResult ExecuteStep();
+    virtual JobStepResult Step();
 
-    virtual void SignalResubmit();
+    virtual void Reset();
 
-    virtual void ReleaseResources(JobReleaseReason reason);
+    virtual void Stop(JobStopReason reason);
 
     virtual float GetProgress();
 
--- a/Plugins/Include/orthanc/OrthancCPlugin.h	Thu Sep 06 12:32:02 2018 +0200
+++ b/Plugins/Include/orthanc/OrthancCPlugin.h	Thu Sep 06 16:23:40 2018 +0200
@@ -853,18 +853,18 @@
 
 
   /**
-   * Explains why the job should release its resources. This is
-   * especially important to disambiguate between the "paused"
+   * Explains why the job should stop and release its resources. This
+   * is especially important to disambiguate between the "paused"
    * condition and the "final" conditions (success, failure, or
    * canceled).
    **/
   typedef enum
   {
-    OrthancPluginJobReleaseReason_Success = 1,  /*!< The job has succeeded */
-    OrthancPluginJobReleaseReason_Paused = 2,   /*!< The job was paused, and will be resumed later */
-    OrthancPluginJobReleaseReason_Failure = 3,  /*!< The job has failed, and might be resubmitted later */
-    OrthancPluginJobReleaseReason_Canceled = 4  /*!< The job was canceled, and might be resubmitted later */
-  } OrthancPluginJobReleaseReason;
+    OrthancPluginJobStopReason_Success = 1,  /*!< The job has succeeded */
+    OrthancPluginJobStopReason_Paused = 2,   /*!< The job was paused, and will be resumed later */
+    OrthancPluginJobStopReason_Failure = 3,  /*!< The job has failed, and might be resubmitted later */
+    OrthancPluginJobStopReason_Canceled = 4  /*!< The job was canceled, and might be resubmitted later */
+  } OrthancPluginJobStopReason;
 
 
   /**
@@ -1275,8 +1275,8 @@
   typedef void (*OrthancPluginJobFree) (void* job);
   typedef float (*OrthancPluginJobGetProgress) (void* job);
   typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job);
-  typedef OrthancPluginErrorCode (*OrthancPluginJobReleaseResources) (void* job, 
-                                                                      OrthancPluginJobReleaseReason reason);
+  typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job, 
+                                                          OrthancPluginJobStopReason reason);
   typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job);
   typedef OrthancPluginErrorCode (*OrthancPluginJobsUnserializer) (const char* jobType,
                                                                    const char* serialized);
@@ -6041,31 +6041,31 @@
 
   typedef struct
   {
-    char**                            resultId_;
-    void                             *job_;
-    int                               priority_;
-    const char                       *type_;
-    const char                       *content_;
-    const char                       *serialized_;
-    OrthancPluginJobFree              free_;
-    OrthancPluginJobGetProgress       getProgress_;
-    OrthancPluginJobStep              step_;
-    OrthancPluginJobReleaseResources  releaseResources_;
-    OrthancPluginJobReset             reset_;
+    char**                        resultId_;
+    void                         *job_;
+    int                           priority_;
+    const char                   *type_;
+    const char                   *content_;
+    const char                   *serialized_;
+    OrthancPluginJobFree          free_;
+    OrthancPluginJobGetProgress   getProgress_;
+    OrthancPluginJobStep          step_;
+    OrthancPluginJobStop          stop_;
+    OrthancPluginJobReset         reset_;
   } _OrthancPluginSubmitJob;
 
   ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob(
-    OrthancPluginContext             *context,
-    void                             *job,
-    int                               priority,
-    const char                       *type,
-    const char                       *content,
-    const char                       *serialized,
-    OrthancPluginJobFree              freeJob,
-    OrthancPluginJobGetProgress       getProgress,
-    OrthancPluginJobStep              step,
-    OrthancPluginJobReleaseResources  releaseResources,
-    OrthancPluginJobReset             reset)
+    OrthancPluginContext         *context,
+    void                         *job,
+    int                           priority,
+    const char                   *type,
+    const char                   *content,
+    const char                   *serialized,
+    OrthancPluginJobFree          freeJob,
+    OrthancPluginJobGetProgress   getProgress,
+    OrthancPluginJobStep          step,
+    OrthancPluginJobStop          stop,
+    OrthancPluginJobReset         reset)
   {
     char* resultId = NULL;
 
@@ -6081,7 +6081,7 @@
     params.serialized_ = serialized;
     params.getProgress_ = getProgress;
     params.step_ = step;
-    params.releaseResources_ = releaseResources;
+    params.stop_ = stop;
     params.reset_ = reset;
 
     if (context->InvokeService(context, _OrthancPluginService_SubmitJob, &params) != OrthancPluginErrorCode_Success ||
--- a/UnitTestsSources/MultiThreadingTests.cpp	Thu Sep 06 12:32:02 2018 +0200
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Thu Sep 06 16:23:40 2018 +0200
@@ -95,11 +95,11 @@
     {
     }
 
-    virtual void SignalResubmit()
+    virtual void Reset()
     {
     }
     
-    virtual JobStepResult ExecuteStep()
+    virtual JobStepResult Step()
     {
       if (fails_)
       {
@@ -116,7 +116,7 @@
       }
     }
 
-    virtual void ReleaseResources(JobReleaseReason reason)
+    virtual void Stop(JobStopReason reason)
     {
     }
 
@@ -162,7 +162,7 @@
     {
     }
     
-    virtual void ReleaseResources(JobReleaseReason reason)
+    virtual void Stop(JobStopReason reason)
     {
     }
 
@@ -962,10 +962,10 @@
     job.AddInstance("nope");
     job.AddInstance("world");
     job.SetPermissive(true);
-    ASSERT_THROW(job.ExecuteStep(), OrthancException);  // Not started yet
+    ASSERT_THROW(job.Step(), OrthancException);  // Not started yet
     job.Start();
-    job.ExecuteStep();
-    job.ExecuteStep();
+    job.Step();
+    job.Step();
 
     {
       DummyUnserializer unserializer;
@@ -1016,7 +1016,7 @@
       lock.SetTrailingOperationTimeout(300);
     }
 
-    ASSERT_EQ(JobStepCode_Continue, job.ExecuteStep().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
 
     {
       GenericJobUnserializer unserializer;