Mercurial > hg > orthanc
diff Core/MultiThreading/BagOfTasksProcessor.cpp @ 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 | b97aa579e85b |
children | 0ae26237569a |
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); } }