Chromium Code Reviews| 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..6a0ae5b2302ec68aa43d4c3d009497970ad3a722 100644 |
| --- a/content/renderer/categorized_worker_pool.cc |
| +++ b/content/renderer/categorized_worker_pool.cc |
| @@ -17,6 +17,8 @@ |
| namespace content { |
| namespace { |
| +const int kHeartbeatIntervalInSeconds = 60; // 1 minute |
|
robliao
2016/06/07 15:40:30
constexpr
|
| + |
| // A thread which forwards to CategorizedWorkerPool::Run with the runnable |
| // categories. |
| class CategorizedWorkerPoolThread : public base::SimpleThread { |
| @@ -239,12 +241,26 @@ 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 (true) { |
|
robliao
2016/06/07 15:40:30
while (has_ready_to_run_tasks_cv->TimedWait(timeou
|
| + if (!has_ready_to_run_tasks_cv->TimedWait(timeout)) |
| + break; |
| + |
| + TRACE_EVENT_INSTANT0( |
| + "heartbeat", "CategorizedWorkerPool::HeartbeatDuringWaitForMoreTasks", |
| + TRACE_EVENT_SCOPE_THREAD); |
| + } |
| +} |
| + |
| void CategorizedWorkerPool::FlushForTesting() { |
| base::AutoLock lock(lock_); |