aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/ok.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ok.cpp')
-rw-r--r--tools/ok.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/ok.cpp b/tools/ok.cpp
index 75c32730df..d0d3960afe 100644
--- a/tools/ok.cpp
+++ b/tools/ok.cpp
@@ -14,9 +14,10 @@
#include "SkPicture.h"
#include "SkSurface.h"
#include "gm.h"
-#include <deque>
+#include <chrono>
#include <functional>
#include <future>
+#include <list>
#include <map>
#include <memory>
#include <regex>
@@ -49,7 +50,7 @@ struct SerialEngine : Engine {
};
struct ThreadEngine : Engine {
- std::deque<std::future<Status>> live;
+ std::list<std::future<Status>> live;
bool spawn(std::function<Status(void)> fn) override {
live.push_back(std::async(std::launch::async, fn));
@@ -60,9 +61,16 @@ struct ThreadEngine : Engine {
if (live.empty()) {
return Status::None;
}
- Status s = live.front().get();
- live.pop_front();
- return s;
+
+ for (;;) {
+ for (auto it = live.begin(); it != live.end(); it++) {
+ if (it->wait_for(std::chrono::seconds::zero()) == std::future_status::ready) {
+ Status s = it->get();
+ live.erase(it);
+ return s;
+ }
+ }
+ }
}
};