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

Unified Diff: content/renderer/categorized_worker_pool.cc

Issue 2047433004: content: Add heartbeat trace for CategorizedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 6 months 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 | « content/renderer/categorized_worker_pool.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/categorized_worker_pool.cc
diff --git a/content/renderer/categorized_worker_pool.cc b/content/renderer/categorized_worker_pool.cc
index 41814b4bcd324b2c0f2af1d20b45cc570a4afb35..5806284c0f1a40b423083f5b00acf9003e2acac1 100644
--- a/content/renderer/categorized_worker_pool.cc
+++ b/content/renderer/categorized_worker_pool.cc
@@ -17,6 +17,8 @@
namespace content {
namespace {
+constexpr int kHeartbeatIntervalInSeconds = 60; // 1 minute
+
// A thread which forwards to CategorizedWorkerPool::Run with the runnable
// categories.
class CategorizedWorkerPoolThread : public base::SimpleThread {
@@ -239,12 +241,23 @@ void CategorizedWorkerPool::Run(
break;
// Wait for more tasks.
- has_ready_to_run_tasks_cv->Wait();
+ WaitForMoreTasksWithLockAcquired(has_ready_to_run_tasks_cv);
continue;
}
}
}
+void CategorizedWorkerPool::WaitForMoreTasksWithLockAcquired(
+ base::ConditionVariable* has_ready_to_run_tasks_cv) {
+ const base::TimeDelta timeout =
+ base::TimeDelta::FromSeconds(kHeartbeatIntervalInSeconds);
+ while (has_ready_to_run_tasks_cv->TimedWait(timeout)) {
+ TRACE_EVENT_INSTANT0(
+ "heartbeat", "CategorizedWorkerPool::HeartbeatDuringWaitForMoreTasks",
+ TRACE_EVENT_SCOPE_THREAD);
+ }
+}
+
void CategorizedWorkerPool::FlushForTesting() {
base::AutoLock lock(lock_);
« no previous file with comments | « content/renderer/categorized_worker_pool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698