# HG changeset patch # User Sebastien Jodogne # Date 1457335762 -3600 # Node ID 6ac7f31fc5433a776395198bc497223000a11468 # Parent 369897749653e87720b3176dbc2a6cac03f49fac fix freeze if empty bag of tasks diff -r 369897749653 -r 6ac7f31fc543 Core/MultiThreading/BagOfTasksProcessor.cpp --- 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); } } diff -r 369897749653 -r 6ac7f31fc543 Core/MultiThreading/BagOfTasksProcessor.h --- 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) { }