Add hacky Wait method to prioritizedworkqueue

This commit is contained in:
Henrik Rydgård
2013-11-20 14:41:58 +01:00
parent e497942827
commit feb521fd41
2 changed files with 19 additions and 1 deletions
+15
View File
@@ -1,5 +1,6 @@
#include "base/functional.h"
#include "base/logging.h"
#include "base/timeutil.h"
#include "thread/thread.h"
#include "thread/prioritizedworkqueue.h"
@@ -66,6 +67,20 @@ PrioritizedWorkQueueItem *PrioritizedWorkQueue::Pop() {
}
}
void PrioritizedWorkQueue::Wait(PrioritizedWorkQueueItem *item) {
while (true) {
bool stillThere = false;
lock_guard guard(mutex_);
for (int i = 0; i < queue_.empty(); i++) {
if (queue_[i] == item)
stillThere = true;
}
if (!stillThere)
break;
sleep_ms(100);
}
}
// TODO: This feels ugly. Revisit later.
static std::thread *workThread;