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

Side by Side Diff: base/task_scheduler/task_tracker.cc

Issue 2557083002: Run ScopedTaskScheduler tasks synchronously. (Closed)
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.h ('k') | base/test/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/task_annotator.h" 10 #include "base/debug/task_annotator.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 bool TaskTracker::HasShutdownStarted() const { 281 bool TaskTracker::HasShutdownStarted() const {
282 return state_->HasShutdownStarted(); 282 return state_->HasShutdownStarted();
283 } 283 }
284 284
285 bool TaskTracker::IsShutdownComplete() const { 285 bool TaskTracker::IsShutdownComplete() const {
286 AutoSchedulerLock auto_lock(shutdown_lock_); 286 AutoSchedulerLock auto_lock(shutdown_lock_);
287 return shutdown_event_ && shutdown_event_->IsSignaled(); 287 return shutdown_event_ && shutdown_event_->IsSignaled();
288 } 288 }
289 289
290 void TaskTracker::SetHasShutdownStartedForTesting() { 290 void TaskTracker::SetHasShutdownStartedForTesting() {
291 AutoSchedulerLock auto_lock(shutdown_lock_);
292
293 // Create a dummy |shutdown_event_| to satisfy TaskTracker's expectation of
294 // its existence during shutdown (e.g. in OnBlockingShutdownTasksComplete()).
295 shutdown_event_.reset(
296 new WaitableEvent(WaitableEvent::ResetPolicy::MANUAL,
297 WaitableEvent::InitialState::NOT_SIGNALED));
298
291 state_->StartShutdown(); 299 state_->StartShutdown();
292 } 300 }
293 301
294 void TaskTracker::PerformRunTask(std::unique_ptr<Task> task) { 302 void TaskTracker::PerformRunTask(std::unique_ptr<Task> task) {
295 debug::TaskAnnotator().RunTask(kQueueFunctionName, task.get()); 303 debug::TaskAnnotator().RunTask(kQueueFunctionName, task.get());
296 } 304 }
297 305
298 void TaskTracker::PerformShutdown() { 306 void TaskTracker::PerformShutdown() {
299 { 307 {
300 AutoSchedulerLock auto_lock(shutdown_lock_); 308 AutoSchedulerLock auto_lock(shutdown_lock_);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); 458 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1);
451 DCHECK_GE(new_num_pending_undelayed_tasks, 0); 459 DCHECK_GE(new_num_pending_undelayed_tasks, 0);
452 if (new_num_pending_undelayed_tasks == 0) { 460 if (new_num_pending_undelayed_tasks == 0) {
453 AutoSchedulerLock auto_lock(flush_lock_); 461 AutoSchedulerLock auto_lock(flush_lock_);
454 flush_cv_->Signal(); 462 flush_cv_->Signal();
455 } 463 }
456 } 464 }
457 465
458 } // namespace internal 466 } // namespace internal
459 } // namespace base 467 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.h ('k') | base/test/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698