Mercurial > hg > orthanc
comparison Core/JobsEngine/JobsRegistry.h @ 2673:8e0bc055d18c jobs
JobsRegistry::IObserver
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 11 Jun 2018 16:29:33 +0200 |
parents | eaf10085ffa1 |
children | 251614c2edac |
comparison
equal
deleted
inserted
replaced
2672:3efc44fac209 | 2673:8e0bc055d18c |
---|---|
53 namespace Orthanc | 53 namespace Orthanc |
54 { | 54 { |
55 // This class handles the state machine of the jobs engine | 55 // This class handles the state machine of the jobs engine |
56 class JobsRegistry : public boost::noncopyable | 56 class JobsRegistry : public boost::noncopyable |
57 { | 57 { |
58 public: | |
59 class IObserver : public boost::noncopyable | |
60 { | |
61 public: | |
62 virtual ~IObserver() | |
63 { | |
64 } | |
65 | |
66 virtual void SignalJobSubmitted(const std::string& jobId) = 0; | |
67 | |
68 virtual void SignalJobSuccess(const std::string& jobId) = 0; | |
69 | |
70 virtual void SignalJobFailure(const std::string& jobId) = 0; | |
71 }; | |
72 | |
58 private: | 73 private: |
59 class JobHandler; | 74 class JobHandler; |
60 | 75 |
61 struct PriorityComparator | 76 struct PriorityComparator |
62 { | 77 { |
78 RetryJobs retryJobs_; | 93 RetryJobs retryJobs_; |
79 | 94 |
80 boost::condition_variable pendingJobAvailable_; | 95 boost::condition_variable pendingJobAvailable_; |
81 boost::condition_variable someJobComplete_; | 96 boost::condition_variable someJobComplete_; |
82 size_t maxCompletedJobs_; | 97 size_t maxCompletedJobs_; |
98 | |
99 IObserver* observer_; | |
83 | 100 |
84 | 101 |
85 #ifndef NDEBUG | 102 #ifndef NDEBUG |
86 bool IsPendingJob(const JobHandler& job) const; | 103 bool IsPendingJob(const JobHandler& job) const; |
87 | 104 |
116 JobHandler* handler, | 133 JobHandler* handler, |
117 bool keepLastChangeTime); | 134 bool keepLastChangeTime); |
118 | 135 |
119 public: | 136 public: |
120 JobsRegistry() : | 137 JobsRegistry() : |
121 maxCompletedJobs_(10) | 138 maxCompletedJobs_(10), |
139 observer_(NULL) | |
122 { | 140 { |
123 } | 141 } |
124 | 142 |
125 JobsRegistry(IJobUnserializer& unserializer, | 143 JobsRegistry(IJobUnserializer& unserializer, |
126 const Json::Value& s); | 144 const Json::Value& s); |
159 | 177 |
160 void ScheduleRetries(); | 178 void ScheduleRetries(); |
161 | 179 |
162 bool GetState(JobState& state, | 180 bool GetState(JobState& state, |
163 const std::string& id); | 181 const std::string& id); |
182 | |
183 void SetObserver(IObserver& observer); | |
184 | |
185 void ResetObserver(); | |
164 | 186 |
165 class RunningJob : public boost::noncopyable | 187 class RunningJob : public boost::noncopyable |
166 { | 188 { |
167 private: | 189 private: |
168 JobsRegistry& registry_; | 190 JobsRegistry& registry_; |