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

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

Issue 2891363005: Add ScopedTaskEnvironment::ExecutionControlMode. (Closed)
Patch Set: self-review Created 3 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 unified diff | Download patch
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 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 } 382 }
383 } 383 }
384 384
385 #if DCHECK_IS_ON() 385 #if DCHECK_IS_ON()
386 bool TaskTracker::IsPostingBlockShutdownTaskAfterShutdownAllowed() { 386 bool TaskTracker::IsPostingBlockShutdownTaskAfterShutdownAllowed() {
387 return false; 387 return false;
388 } 388 }
389 #endif 389 #endif
390 390
391 int TaskTracker::GetNumPendingUndelayedTasksForTesting() const {
392 // No barrier is required, but there is no function in base/ to read an atomic
393 // variable without a barrier.
394 return subtle::Acquire_Load(&num_pending_undelayed_tasks_);
395 }
396
391 bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) { 397 bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) {
392 if (shutdown_behavior == TaskShutdownBehavior::BLOCK_SHUTDOWN) { 398 if (shutdown_behavior == TaskShutdownBehavior::BLOCK_SHUTDOWN) {
393 // BLOCK_SHUTDOWN tasks block shutdown between the moment they are posted 399 // BLOCK_SHUTDOWN tasks block shutdown between the moment they are posted
394 // and the moment they complete their execution. 400 // and the moment they complete their execution.
395 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown(); 401 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown();
396 402
397 if (shutdown_started) { 403 if (shutdown_started) {
398 AutoSchedulerLock auto_lock(shutdown_lock_); 404 AutoSchedulerLock auto_lock(shutdown_lock_);
399 405
400 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an 406 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 task_latency_histograms_[static_cast<int>(task->traits.priority())] 518 task_latency_histograms_[static_cast<int>(task->traits.priority())]
513 [task->traits.may_block() || 519 [task->traits.may_block() ||
514 task->traits.with_base_sync_primitives() 520 task->traits.with_base_sync_primitives()
515 ? 1 521 ? 1
516 : 0] 522 : 0]
517 ->Add(task_latency.InMicroseconds()); 523 ->Add(task_latency.InMicroseconds());
518 } 524 }
519 525
520 } // namespace internal 526 } // namespace internal
521 } // namespace base 527 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698