# HG changeset patch # User Sebastien Jodogne # Date 1477488999 -7200 # Node ID 5b818f677dd6468583f163b9604af016fccf64dc # Parent d5c29fd74ffa5838e13446986c7bef78af3b9136 fix in BagOfTasksProcessor diff -r d5c29fd74ffa -r 5b818f677dd6 Core/MultiThreading/BagOfTasksProcessor.cpp --- a/Core/MultiThreading/BagOfTasksProcessor.cpp Wed Oct 26 13:32:02 2016 +0200 +++ b/Core/MultiThreading/BagOfTasksProcessor.cpp Wed Oct 26 15:36:39 2016 +0200 @@ -33,8 +33,10 @@ #include "../PrecompiledHeaders.h" #include "BagOfTasksProcessor.h" +#include "../Logging.h" #include "../OrthancException.h" +#include namespace Orthanc { @@ -58,12 +60,19 @@ { return command_->Execute(); } - catch (OrthancException&) + catch (OrthancException& e) { + LOG(ERROR) << "Exception while processing a bag of tasks: " << e.What(); return false; } - catch (std::runtime_error&) + catch (std::runtime_error& e) { + LOG(ERROR) << "Runtime exception while processing a bag of tasks: " << e.what(); + return false; + } + catch (...) + { + LOG(ERROR) << "Native exception while processing a bag of tasks"; return false; } } @@ -75,6 +84,20 @@ }; + void BagOfTasksProcessor::SignalProgress(Task& task, + Bag& bag) + { + assert(bag.done_ < bag.size_); + + bag.done_ += 1; + + if (bag.done_ == bag.size_) + { + exitStatus_[task.GetBag()] = (bag.status_ == BagStatus_Running); + bagFinished_.notify_all(); + } + } + void BagOfTasksProcessor::Worker(BagOfTasksProcessor* that) { while (that->continue_) @@ -93,8 +116,9 @@ if (bag->second.status_ != BagStatus_Running) { - // This bag of task has failed or is tagged as canceled, do nothing - bag->second.done_ += 1; + // Do not execute this task, as its parent bag of tasks + // has failed or is tagged as canceled + that->SignalProgress(task, bag->second); continue; } } @@ -112,14 +136,7 @@ bag->second.status_ = BagStatus_Failed; } - assert(bag->second.done_ < bag->second.size_); - bag->second.done_ += 1; - - if (bag->second.done_ == bag->second.size_) - { - that->exitStatus_[task.GetBag()] = (bag->second.status_ == BagStatus_Running); - that->bagFinished_.notify_all(); - } + that->SignalProgress(task, bag->second); } } } diff -r d5c29fd74ffa -r 5b818f677dd6 Core/MultiThreading/BagOfTasksProcessor.h --- a/Core/MultiThreading/BagOfTasksProcessor.h Wed Oct 26 13:32:02 2016 +0200 +++ b/Core/MultiThreading/BagOfTasksProcessor.h Wed Oct 26 15:36:39 2016 +0200 @@ -97,6 +97,9 @@ float GetProgress(int64_t bag); + void SignalProgress(Task& task, + Bag& bag); + public: class Handle : public boost::noncopyable {