Mercurial > hg > orthanc-wsi
comparison Framework/MultiThreading/BagOfTasksProcessor.cpp @ 236:b0ee417b667a
migrating new definitions in namespace Orthanc to namespace OrthancWSI
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 23 Feb 2021 10:27:58 +0100 |
parents | 1e864138f0da |
children | 49f647ed1b4c |
comparison
equal
deleted
inserted
replaced
235:8a5b2b068e52 | 236:b0ee417b667a |
---|---|
25 #include <Logging.h> | 25 #include <Logging.h> |
26 #include <OrthancException.h> | 26 #include <OrthancException.h> |
27 | 27 |
28 #include <stdio.h> | 28 #include <stdio.h> |
29 | 29 |
30 namespace Orthanc | 30 namespace OrthancWSI |
31 { | 31 { |
32 class BagOfTasksProcessor::Task : public IDynamicObject | 32 class BagOfTasksProcessor::Task : public Orthanc::IDynamicObject |
33 { | 33 { |
34 private: | 34 private: |
35 uint64_t bag_; | 35 uint64_t bag_; |
36 std::unique_ptr<ICommand> command_; | 36 std::unique_ptr<ICommand> command_; |
37 | 37 |
47 { | 47 { |
48 try | 48 try |
49 { | 49 { |
50 return command_->Execute(); | 50 return command_->Execute(); |
51 } | 51 } |
52 catch (OrthancException& e) | 52 catch (Orthanc::OrthancException& e) |
53 { | 53 { |
54 LOG(ERROR) << "Exception while processing a bag of tasks: " << e.What(); | 54 LOG(ERROR) << "Exception while processing a bag of tasks: " << e.What(); |
55 return false; | 55 return false; |
56 } | 56 } |
57 catch (std::runtime_error& e) | 57 catch (std::runtime_error& e) |
89 | 89 |
90 void BagOfTasksProcessor::Worker(BagOfTasksProcessor* that) | 90 void BagOfTasksProcessor::Worker(BagOfTasksProcessor* that) |
91 { | 91 { |
92 while (that->continue_) | 92 while (that->continue_) |
93 { | 93 { |
94 std::unique_ptr<IDynamicObject> obj(that->queue_.Dequeue(100)); | 94 std::unique_ptr<Orthanc::IDynamicObject> obj(that->queue_.Dequeue(100)); |
95 if (obj.get() != NULL) | 95 if (obj.get() != NULL) |
96 { | 96 { |
97 Task& task = *dynamic_cast<Task*>(obj.get()); | 97 Task& task = *dynamic_cast<Task*>(obj.get()); |
98 | 98 |
99 { | 99 { |
204 countBags_(0), | 204 countBags_(0), |
205 continue_(true) | 205 continue_(true) |
206 { | 206 { |
207 if (countThreads == 0) | 207 if (countThreads == 0) |
208 { | 208 { |
209 throw OrthancException(ErrorCode_ParameterOutOfRange); | 209 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
210 } | 210 } |
211 | 211 |
212 threads_.resize(countThreads); | 212 threads_.resize(countThreads); |
213 | 213 |
214 for (size_t i = 0; i < threads_.size(); i++) | 214 for (size_t i = 0; i < threads_.size(); i++) |