Mercurial > hg > orthanc
changeset 1923:6ac7f31fc543
fix freeze if empty bag of tasks
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Mar 2016 08:29:22 +0100 |
parents | 369897749653 |
children | 6c73df12ca51 |
files | Core/MultiThreading/BagOfTasksProcessor.cpp Core/MultiThreading/BagOfTasksProcessor.h |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/MultiThreading/BagOfTasksProcessor.cpp Fri Mar 04 17:53:19 2016 +0100 +++ b/Core/MultiThreading/BagOfTasksProcessor.cpp Mon Mar 07 08:29:22 2016 +0100 @@ -236,6 +236,11 @@ BagOfTasksProcessor::Handle* BagOfTasksProcessor::Submit(BagOfTasks& tasks) { + if (tasks.GetSize() == 0) + { + return new Handle(*this, 0, true); + } + boost::mutex::scoped_lock lock(mutex_); uint64_t id = countBags_; @@ -249,6 +254,6 @@ queue_.Enqueue(new Task(id, tasks.Pop())); } - return new Handle(*this, id); + return new Handle(*this, id, false); } }
--- a/Core/MultiThreading/BagOfTasksProcessor.h Fri Mar 04 17:53:19 2016 +0100 +++ b/Core/MultiThreading/BagOfTasksProcessor.h Mon Mar 07 08:29:22 2016 +0100 @@ -109,10 +109,11 @@ bool status_; Handle(BagOfTasksProcessor& that, - uint64_t bag) : + uint64_t bag, + bool empty) : that_(that), bag_(bag), - hasJoined_(false) + hasJoined_(empty) { }