Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1922:369897749653 | 1923:6ac7f31fc543 |
---|---|
234 } | 234 } |
235 | 235 |
236 | 236 |
237 BagOfTasksProcessor::Handle* BagOfTasksProcessor::Submit(BagOfTasks& tasks) | 237 BagOfTasksProcessor::Handle* BagOfTasksProcessor::Submit(BagOfTasks& tasks) |
238 { | 238 { |
239 if (tasks.GetSize() == 0) | |
240 { | |
241 return new Handle(*this, 0, true); | |
242 } | |
243 | |
239 boost::mutex::scoped_lock lock(mutex_); | 244 boost::mutex::scoped_lock lock(mutex_); |
240 | 245 |
241 uint64_t id = countBags_; | 246 uint64_t id = countBags_; |
242 countBags_ += 1; | 247 countBags_ += 1; |
243 | 248 |
247 while (!tasks.IsEmpty()) | 252 while (!tasks.IsEmpty()) |
248 { | 253 { |
249 queue_.Enqueue(new Task(id, tasks.Pop())); | 254 queue_.Enqueue(new Task(id, tasks.Pop())); |
250 } | 255 } |
251 | 256 |
252 return new Handle(*this, id); | 257 return new Handle(*this, id, false); |
253 } | 258 } |
254 } | 259 } |