From 9fa99614ec4e695f6e7e9fe19508758757543b8c Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 27 Apr 2017 09:50:34 -0400 Subject: In ok thread mode, use wait_util instead of wait_for. wait_for(delta) is wait_until(steady_clock::now() + delta) under the hood, so using wait_for() like this implies an extra call to now() that we can avoid by using wait_until(). We can hoist that call out and just do it once... the past stays the past. This is not super important. Just noticed while profiling. It's nice to keep the overhead of the ok tool down so the real work can show. :) Change-Id: I89d25a800b63ebcfc229b5b3aa3f2dd621f4e7b4 Reviewed-on: https://skia-review.googlesource.com/14480 Commit-Queue: Mike Klein Reviewed-by: Herb Derby --- tools/ok.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/ok.cpp') diff --git a/tools/ok.cpp b/tools/ok.cpp index b8c4f5b593..10f9afdbe0 100644 --- a/tools/ok.cpp +++ b/tools/ok.cpp @@ -119,6 +119,7 @@ struct SerialEngine : Engine { struct ThreadEngine : Engine { std::list> live; + const std::chrono::steady_clock::time_point the_past = std::chrono::steady_clock::now(); bool spawn(std::function fn) override { live.push_back(std::async(std::launch::async, fn)); @@ -132,7 +133,7 @@ struct ThreadEngine : Engine { for (;;) { for (auto it = live.begin(); it != live.end(); it++) { - if (it->wait_for(std::chrono::seconds::zero()) == std::future_status::ready) { + if (it->wait_until(the_past) == std::future_status::ready) { Status s = it->get(); live.erase(it); return s; -- cgit v1.2.3