Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: runtime/vm/thread_pool.cc

Issue 2582543003: Update GC stats, ThreadPool, Timer and ScopedTimer to use monotonic time. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/scope_timer.h ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_pool.cc
diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc
index 40ca9d57ec344bd7763db51a9c4a53ab695dd953..8050833851e76dcf9ebf7ad25252bb842e24aa91 100644
--- a/runtime/vm/thread_pool.cc
+++ b/runtime/vm/thread_pool.cc
@@ -370,18 +370,20 @@ void ThreadPool::Worker::SetTask(Task* task) {
static int64_t ComputeTimeout(int64_t idle_start) {
- if (FLAG_worker_timeout_millis <= 0) {
+ int64_t worker_timeout_micros =
+ FLAG_worker_timeout_millis * kMicrosecondsPerMillisecond;
+ if (worker_timeout_micros <= 0) {
// No timeout.
return 0;
} else {
- int64_t waited = OS::GetCurrentTimeMillis() - idle_start;
- if (waited >= FLAG_worker_timeout_millis) {
+ int64_t waited = OS::GetCurrentMonotonicMicros() - idle_start;
+ if (waited >= worker_timeout_micros) {
// We must have gotten a spurious wakeup just before we timed
// out. Give the worker one last desperate chance to live. We
// are merciful.
return 1;
} else {
- return FLAG_worker_timeout_millis - waited;
+ return worker_timeout_micros - waited;
}
}
}
@@ -408,9 +410,9 @@ bool ThreadPool::Worker::Loop() {
}
ASSERT(!done_);
pool_->SetIdleAndReapExited(this);
- idle_start = OS::GetCurrentTimeMillis();
+ idle_start = OS::GetCurrentMonotonicMicros();
while (true) {
- Monitor::WaitResult result = ml.Wait(ComputeTimeout(idle_start));
+ Monitor::WaitResult result = ml.WaitMicros(ComputeTimeout(idle_start));
if (task_ != NULL) {
// We've found a task. Process it, regardless of whether the
// worker is done_.
« no previous file with comments | « runtime/vm/scope_timer.h ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698