Mercurial > hg > orthanc
comparison Core/JobsEngine/JobsRegistry.h @ 4022:a2e4edc7b9aa more-changes
wip: adding job changes
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 09 Jun 2020 08:46:52 +0200 |
parents | 94f4a18a79cc |
children | 1d2b31fc782f |
comparison
equal
deleted
inserted
replaced
4013:1e9f6d706237 | 4022:a2e4edc7b9aa |
---|---|
84 { | 84 { |
85 bool operator() (JobHandler*& a, | 85 bool operator() (JobHandler*& a, |
86 JobHandler*& b) const; | 86 JobHandler*& b) const; |
87 }; | 87 }; |
88 | 88 |
89 typedef std::set<IObserver*> Observers; | |
89 typedef std::map<std::string, JobHandler*> JobsIndex; | 90 typedef std::map<std::string, JobHandler*> JobsIndex; |
90 typedef std::list<JobHandler*> CompletedJobs; | 91 typedef std::list<JobHandler*> CompletedJobs; |
91 typedef std::set<JobHandler*> RetryJobs; | 92 typedef std::set<JobHandler*> RetryJobs; |
92 typedef std::priority_queue<JobHandler*, | 93 typedef std::priority_queue<JobHandler*, |
93 std::vector<JobHandler*>, // Could be a "std::deque" | 94 std::vector<JobHandler*>, // Could be a "std::deque" |
101 | 102 |
102 boost::condition_variable pendingJobAvailable_; | 103 boost::condition_variable pendingJobAvailable_; |
103 boost::condition_variable someJobComplete_; | 104 boost::condition_variable someJobComplete_; |
104 size_t maxCompletedJobs_; | 105 size_t maxCompletedJobs_; |
105 | 106 |
106 IObserver* observer_; | 107 boost::shared_mutex observersMutex_; |
108 Observers observers_; | |
107 | 109 |
108 | 110 |
109 #ifndef NDEBUG | 111 #ifndef NDEBUG |
110 bool IsPendingJob(const JobHandler& job) const; | 112 bool IsPendingJob(const JobHandler& job) const; |
111 | 113 |
139 void SubmitInternal(std::string& id, | 141 void SubmitInternal(std::string& id, |
140 JobHandler* handler); | 142 JobHandler* handler); |
141 | 143 |
142 public: | 144 public: |
143 JobsRegistry(size_t maxCompletedJobs) : | 145 JobsRegistry(size_t maxCompletedJobs) : |
144 maxCompletedJobs_(maxCompletedJobs), | 146 maxCompletedJobs_(maxCompletedJobs) |
145 observer_(NULL) | |
146 { | 147 { |
147 } | 148 } |
148 | 149 |
149 JobsRegistry(IJobUnserializer& unserializer, | 150 JobsRegistry(IJobUnserializer& unserializer, |
150 const Json::Value& s, | 151 const Json::Value& s, |
193 void ScheduleRetries(); | 194 void ScheduleRetries(); |
194 | 195 |
195 bool GetState(JobState& state, | 196 bool GetState(JobState& state, |
196 const std::string& id); | 197 const std::string& id); |
197 | 198 |
198 void SetObserver(IObserver& observer); | 199 void AddObserver(IObserver& observer); |
199 | 200 |
200 void ResetObserver(); | 201 void ResetObserver(IObserver& observer); |
201 | 202 |
202 void GetStatistics(unsigned int& pending, | 203 void GetStatistics(unsigned int& pending, |
203 unsigned int& running, | 204 unsigned int& running, |
204 unsigned int& success, | 205 unsigned int& success, |
205 unsigned int& errors); | 206 unsigned int& errors); |