comparison OrthancServer/Sources/ServerJobs/ResourceModificationJob.h @ 5130:f2dcdbe05884

ResourceModification jobs can now use multiple threads
author Alain Mazy <am@osimis.io>
date Thu, 05 Jan 2023 17:24:43 +0100
parents 6eff25f70121
children e71b22a43c0b
comparison
equal deleted inserted replaced
5128:ede035d48b8e 5130:f2dcdbe05884
21 21
22 22
23 #pragma once 23 #pragma once
24 24
25 #include "../../../OrthancFramework/Sources/DicomParsing/DicomModification.h" 25 #include "../../../OrthancFramework/Sources/DicomParsing/DicomModification.h"
26 #include "../../../OrthancFramework/Sources/MultiThreading/RunnableWorkersPool.h"
26 #include "../DicomInstanceOrigin.h" 27 #include "../DicomInstanceOrigin.h"
27 #include "CleaningInstancesJob.h" 28 #include "ThreadedSetOfInstancesJob.h"
29 #include <boost/thread/recursive_mutex.hpp>
28 30
29 namespace Orthanc 31 namespace Orthanc
30 { 32 {
31 class ServerContext; 33 class ServerContext;
32 34
33 class ResourceModificationJob : public CleaningInstancesJob 35 class ResourceModificationJob : public ThreadedSetOfInstancesJob
34 { 36 {
35 private: 37 private:
36 class IOutput : public boost::noncopyable 38 class IOutput : public boost::noncopyable
37 { 39 {
38 public: 40 public:
47 virtual bool IsSingleResource() const = 0; 49 virtual bool IsSingleResource() const = 0;
48 }; 50 };
49 51
50 class SingleOutput; 52 class SingleOutput;
51 class MultipleOutputs; 53 class MultipleOutputs;
54
55 mutable boost::recursive_mutex outputMutex_;
52 56
53 std::unique_ptr<DicomModification> modification_; 57 std::unique_ptr<DicomModification> modification_;
54 boost::shared_ptr<IOutput> output_; 58 boost::shared_ptr<IOutput> output_;
55 bool isAnonymization_; 59 bool isAnonymization_;
56 DicomInstanceOrigin origin_; 60 DicomInstanceOrigin origin_;
57 bool transcode_; 61 bool transcode_;
58 DicomTransferSyntax transferSyntax_; 62 DicomTransferSyntax transferSyntax_;
59 63
60 protected: 64 protected:
61 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE; 65 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE; // from ThreadedSetOfInstancesJob
62 66
63 public: 67 public:
64 explicit ResourceModificationJob(ServerContext& context); 68 explicit ResourceModificationJob(ServerContext& context, unsigned int workersCount);
65 69
66 ResourceModificationJob(ServerContext& context, 70 ResourceModificationJob(ServerContext& context,
67 const Json::Value& serialized); 71 const Json::Value& serialized);
68 72
69 // NB: The "outputLevel" only controls the output format, and 73 // NB: The "outputLevel" only controls the output format, and
107 bool IsSingleResourceModification() const; 111 bool IsSingleResourceModification() const;
108 112
109 // Only possible if "IsSingleResourceModification()" 113 // Only possible if "IsSingleResourceModification()"
110 ResourceType GetOutputLevel() const; 114 ResourceType GetOutputLevel() const;
111 115
112 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE
113 {
114 }
115
116 virtual void GetJobType(std::string& target) ORTHANC_OVERRIDE 116 virtual void GetJobType(std::string& target) ORTHANC_OVERRIDE
117 { 117 {
118 target = "ResourceModification"; 118 target = "ResourceModification";
119 } 119 }
120 120