Mercurial > hg > orthanc
comparison OrthancFramework/Sources/JobsEngine/JobsEngine.cpp @ 4295:90f91b78d708
applied log categories
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 05 Nov 2020 12:01:11 +0100 |
parents | bf7b9edf6b81 |
children | 3af1d763763a |
comparison
equal
deleted
inserted
replaced
4294:0923247e69f6 | 4295:90f91b78d708 |
---|---|
120 void JobsEngine::Worker(JobsEngine* engine, | 120 void JobsEngine::Worker(JobsEngine* engine, |
121 size_t workerIndex) | 121 size_t workerIndex) |
122 { | 122 { |
123 assert(engine != NULL); | 123 assert(engine != NULL); |
124 | 124 |
125 LOG(INFO) << "Worker thread " << workerIndex << " has started"; | 125 CLOG(INFO, JOBS) << "Worker thread " << workerIndex << " has started"; |
126 | 126 |
127 while (engine->IsRunning()) | 127 while (engine->IsRunning()) |
128 { | 128 { |
129 JobsRegistry::RunningJob running(engine->GetRegistry(), engine->threadSleep_); | 129 JobsRegistry::RunningJob running(engine->GetRegistry(), engine->threadSleep_); |
130 | 130 |
131 if (running.IsValid()) | 131 if (running.IsValid()) |
132 { | 132 { |
133 LOG(INFO) << "Executing job with priority " << running.GetPriority() | 133 CLOG(INFO, JOBS) << "Executing job with priority " << running.GetPriority() |
134 << " in worker thread " << workerIndex << ": " << running.GetId(); | 134 << " in worker thread " << workerIndex << ": " << running.GetId(); |
135 | 135 |
136 while (engine->IsRunning()) | 136 while (engine->IsRunning()) |
137 { | 137 { |
138 if (!engine->ExecuteStep(running, workerIndex)) | 138 if (!engine->ExecuteStep(running, workerIndex)) |
139 { | 139 { |
157 JobsEngine::~JobsEngine() | 157 JobsEngine::~JobsEngine() |
158 { | 158 { |
159 if (state_ != State_Setup && | 159 if (state_ != State_Setup && |
160 state_ != State_Done) | 160 state_ != State_Done) |
161 { | 161 { |
162 LOG(ERROR) << "INTERNAL ERROR: JobsEngine::Stop() should be invoked manually to avoid mess in the destruction order!"; | 162 CLOG(ERROR, JOBS) << "INTERNAL ERROR: JobsEngine::Stop() should be invoked manually to avoid mess in the destruction order!"; |
163 Stop(); | 163 Stop(); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 | 167 |
267 workers_[i] = new boost::thread(Worker, this, i); | 267 workers_[i] = new boost::thread(Worker, this, i); |
268 } | 268 } |
269 | 269 |
270 state_ = State_Running; | 270 state_ = State_Running; |
271 | 271 |
272 LOG(WARNING) << "The jobs engine has started with " << workers_.size() << " threads"; | 272 CLOG(WARNING, JOBS) << "The jobs engine has started with " << workers_.size() << " threads"; |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 void JobsEngine::Stop() | 276 void JobsEngine::Stop() |
277 { | 277 { |
284 } | 284 } |
285 | 285 |
286 state_ = State_Stopping; | 286 state_ = State_Stopping; |
287 } | 287 } |
288 | 288 |
289 LOG(INFO) << "Stopping the jobs engine"; | 289 CLOG(INFO, JOBS) << "Stopping the jobs engine"; |
290 | 290 |
291 if (retryHandler_.joinable()) | 291 if (retryHandler_.joinable()) |
292 { | 292 { |
293 retryHandler_.join(); | 293 retryHandler_.join(); |
294 } | 294 } |
308 { | 308 { |
309 boost::mutex::scoped_lock lock(stateMutex_); | 309 boost::mutex::scoped_lock lock(stateMutex_); |
310 state_ = State_Done; | 310 state_ = State_Done; |
311 } | 311 } |
312 | 312 |
313 LOG(WARNING) << "The jobs engine has stopped"; | 313 CLOG(WARNING, JOBS) << "The jobs engine has stopped"; |
314 } | 314 } |
315 } | 315 } |