comparison Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp @ 2608:25225f0b4f33 jobs

simplification wrt. dicom connection manager
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 19 May 2018 15:50:09 +0200
parents 988936118354
children 2f3007bf0708
comparison
equal deleted inserted replaced
2607:44e268605478 2608:25225f0b4f33
99 bool IsDone() const 99 bool IsDone() const
100 { 100 {
101 return currentInput_ >= originalInputs_.GetSize() + workInputs_.GetSize(); 101 return currentInput_ >= originalInputs_.GetSize() + workInputs_.GetSize();
102 } 102 }
103 103
104 void Step() 104 void Step(IDicomConnectionManager& connectionManager)
105 { 105 {
106 if (IsDone()) 106 if (IsDone())
107 { 107 {
108 throw OrthancException(ErrorCode_BadSequenceOfCalls); 108 throw OrthancException(ErrorCode_BadSequenceOfCalls);
109 } 109 }
118 { 118 {
119 input = &workInputs_.GetValue(currentInput_ - originalInputs_.GetSize()); 119 input = &workInputs_.GetValue(currentInput_ - originalInputs_.GetSize());
120 } 120 }
121 121
122 JobOperationValues outputs; 122 JobOperationValues outputs;
123 operation_->Apply(outputs, *input); 123 operation_->Apply(outputs, *input, connectionManager);
124 124
125 if (!nextOperations_.empty()) 125 if (!nextOperations_.empty())
126 { 126 {
127 std::list<Operation*>::iterator first = nextOperations_.begin(); 127 std::list<Operation*>::iterator first = nextOperations_.begin();
128 outputs.Move((*first)->workInputs_); 128 outputs.Move((*first)->workInputs_);
173 void SequenceOfOperationsJob::Lock::SetTrailingOperationTimeout(unsigned int timeout) 173 void SequenceOfOperationsJob::Lock::SetTrailingOperationTimeout(unsigned int timeout)
174 { 174 {
175 that_.trailingTimeout_ = boost::posix_time::milliseconds(timeout); 175 that_.trailingTimeout_ = boost::posix_time::milliseconds(timeout);
176 } 176 }
177 177
178
179 void SequenceOfOperationsJob::Lock::SetDicomConnectionTimeout(unsigned int timeout)
180 {
181 that_.connectionManager_.SetTimeout(timeout);
182 }
183
178 184
179 size_t SequenceOfOperationsJob::Lock::AddOperation(IJobOperation* operation) 185 size_t SequenceOfOperationsJob::Lock::AddOperation(IJobOperation* operation)
180 { 186 {
181 if (IsDone()) 187 if (IsDone())
182 { 188 {
253 it != observers_.end(); ++it) 259 it != observers_.end(); ++it)
254 { 260 {
255 (*it)->SignalDone(*this); 261 (*it)->SignalDone(*this);
256 } 262 }
257 263
264 connectionManager_.Close();
258 return JobStepResult::Success(); 265 return JobStepResult::Success();
259 } 266 }
260 else 267 else
261 { 268 {
262 LOG(INFO) << "New operation added to the sequence of operations"; 269 LOG(INFO) << "New operation added to the sequence of operations";
271 current_++; 278 current_++;
272 } 279 }
273 280
274 if (current_ < operations_.size()) 281 if (current_ < operations_.size())
275 { 282 {
276 operations_[current_]->Step(); 283 operations_[current_]->Step(connectionManager_);
277 } 284 }
285
286 connectionManager_.CheckTimeout();
278 287
279 return JobStepResult::Continue(); 288 return JobStepResult::Continue();
280 } 289 }
281 290
282 291
292 operations_[i]->Reset(); 301 operations_[i]->Reset();
293 } 302 }
294 } 303 }
295 304
296 305
306 void SequenceOfOperationsJob::ReleaseResources()
307 {
308 boost::mutex::scoped_lock lock(mutex_);
309 connectionManager_.Close();
310 }
311
312
297 float SequenceOfOperationsJob::GetProgress() 313 float SequenceOfOperationsJob::GetProgress()
298 { 314 {
299 boost::mutex::scoped_lock lock(mutex_); 315 boost::mutex::scoped_lock lock(mutex_);
300 316
301 return (static_cast<float>(current_) / 317 return (static_cast<float>(current_) /