Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/task_scheduler/task_tracker.h" | 5 #include "base/task_scheduler/task_tracker.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 PerformShutdown(); | 208 PerformShutdown(); |
| 209 DCHECK(IsShutdownComplete()); | 209 DCHECK(IsShutdownComplete()); |
| 210 | 210 |
| 211 // Unblock Flush() when shutdown completes. | 211 // Unblock Flush() when shutdown completes. |
| 212 AutoSchedulerLock auto_lock(flush_lock_); | 212 AutoSchedulerLock auto_lock(flush_lock_); |
| 213 flush_cv_->Signal(); | 213 flush_cv_->Signal(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void TaskTracker::Flush() { | 216 void TaskTracker::Flush() { |
| 217 AutoSchedulerLock auto_lock(flush_lock_); | 217 AutoSchedulerLock auto_lock(flush_lock_); |
| 218 while (subtle::NoBarrier_Load(&num_pending_undelayed_tasks_) != 0 && | 218 while (subtle::Acquire_Load(&num_pending_undelayed_tasks_) != 0 && |
|
robliao
2017/05/02 14:23:20
What was the failure that caused this?
robliao
2017/05/02 15:44:47
Offline Discussion: The Acquire here is probably n
gab
2017/05/02 20:26:27
My thoughts (no action required):
So the problem
fdoray
2017/05/03 13:17:28
Updating comment in header file: Done.
| |
| 219 !IsShutdownComplete()) { | 219 !IsShutdownComplete()) { |
| 220 flush_cv_->Wait(); | 220 flush_cv_->Wait(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool TaskTracker::WillPostTask(const Task* task) { | 224 bool TaskTracker::WillPostTask(const Task* task) { |
| 225 DCHECK(task); | 225 DCHECK(task); |
| 226 | 226 |
| 227 if (!BeforePostTask(task->traits.shutdown_behavior())) | 227 if (!BeforePostTask(task->traits.shutdown_behavior())) |
| 228 return false; | 228 return false; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 | 477 |
| 478 // This method can only be called after shutdown has started. | 478 // This method can only be called after shutdown has started. |
| 479 DCHECK(state_->HasShutdownStarted()); | 479 DCHECK(state_->HasShutdownStarted()); |
| 480 DCHECK(shutdown_event_); | 480 DCHECK(shutdown_event_); |
| 481 | 481 |
| 482 shutdown_event_->Signal(); | 482 shutdown_event_->Signal(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 void TaskTracker::DecrementNumPendingUndelayedTasks() { | 485 void TaskTracker::DecrementNumPendingUndelayedTasks() { |
| 486 const auto new_num_pending_undelayed_tasks = | 486 const auto new_num_pending_undelayed_tasks = |
| 487 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); | 487 subtle::Barrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); |
|
robliao
2017/05/02 14:23:20
Is this barrier actually necessary? What other mem
robliao
2017/05/02 15:44:48
Offline discussion: The memory writes of the task
| |
| 488 DCHECK_GE(new_num_pending_undelayed_tasks, 0); | 488 DCHECK_GE(new_num_pending_undelayed_tasks, 0); |
| 489 if (new_num_pending_undelayed_tasks == 0) { | 489 if (new_num_pending_undelayed_tasks == 0) { |
| 490 AutoSchedulerLock auto_lock(flush_lock_); | 490 AutoSchedulerLock auto_lock(flush_lock_); |
| 491 flush_cv_->Signal(); | 491 flush_cv_->Signal(); |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 | 494 |
| 495 void TaskTracker::RecordTaskLatencyHistogram(Task* task) { | 495 void TaskTracker::RecordTaskLatencyHistogram(Task* task) { |
| 496 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; | 496 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; |
| 497 task_latency_histograms_[static_cast<int>(task->traits.priority())] | 497 task_latency_histograms_[static_cast<int>(task->traits.priority())] |
| 498 [task->traits.may_block() || | 498 [task->traits.may_block() || |
| 499 task->traits.with_base_sync_primitives() | 499 task->traits.with_base_sync_primitives() |
| 500 ? 1 | 500 ? 1 |
| 501 : 0] | 501 : 0] |
| 502 ->Add(task_latency.InMicroseconds()); | 502 ->Add(task_latency.InMicroseconds()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace internal | 505 } // namespace internal |
| 506 } // namespace base | 506 } // namespace base |
| OLD | NEW |