Oops, forgot this

This commit is contained in:
Henrik Rydgard 2015-10-04 00:14:13 +02:00
parent 50d66f9a19
commit 01b9400223
2 changed files with 18 additions and 0 deletions

View File

@ -32,6 +32,23 @@ void PrioritizedWorkQueue::Flush() {
queue_.clear();
}
void PrioritizedWorkQueue::WaitUntilDone() {
if (queue_.empty())
return;
// This could be made more elegant..
while (true) {
bool empty;
{
lock_guard guard(mutex_);
empty = queue_.empty();
}
if (empty) {
break;
}
sleep_ms(10);
}
}
// The worker should simply call this in a loop. Will block when appropriate.
PrioritizedWorkQueueItem *PrioritizedWorkQueue::Pop() {

View File

@ -34,6 +34,7 @@ public:
void Flush();
bool Done() { return done_; }
void Stop();
void WaitUntilDone();
private:
bool done_;