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

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 2285633003: Test SequencedWorkerPool with redirection to the TaskScheduler. (Closed)
Patch Set: Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #endif 45 #endif
46 46
47 #if !defined(OS_NACL) 47 #if !defined(OS_NACL)
48 #include "base/metrics/histogram.h" 48 #include "base/metrics/histogram.h"
49 #endif 49 #endif
50 50
51 namespace base { 51 namespace base {
52 52
53 namespace { 53 namespace {
54 54
55 // An enum representing the state of all pools. Any given process should only 55 // An enum representing the state of all pools. Any given non-test process
56 // ever transition from NONE_ACTIVE to the active states, transitions between 56 // should only ever transition from NONE_ACTIVE to the active states,
57 // actives states are unexpected. The REDIRECTED_TO_TASK_SCHEDULER transition 57 // transitions between actives states are unexpected. The
58 // occurs when RedirectSequencedWorkerPoolsToTaskSchedulerForProcess() is called 58 // REDIRECTED_TO_TASK_SCHEDULER transition occurs when
59 // and the WORKER_CREATED transition occurs when a Worker needs to be created 59 // RedirectToTaskSchedulerForProcess() is called and the WORKER_CREATED
60 // because the first task was posted and the state is still NONE_ACTIVE. 60 // transition occurs when a Worker needs to be created because the first task
61 // was posted and the state is still NONE_ACTIVE. In a test process,
62 // ResetRedirectToTaskSchedulerForProcessForTesting() causes a transition to
63 // the NONE_ACTIVE state.
61 // TODO(gab): Remove this if http://crbug.com/622400 fails (SequencedWorkerPool 64 // TODO(gab): Remove this if http://crbug.com/622400 fails (SequencedWorkerPool
62 // will be phased out completely otherwise). 65 // will be phased out completely otherwise).
63 enum class AllPoolsState { 66 enum class AllPoolsState {
64 NONE_ACTIVE, 67 NONE_ACTIVE,
65 WORKER_CREATED, 68 WORKER_CREATED,
66 REDIRECTED_TO_TASK_SCHEDULER, 69 REDIRECTED_TO_TASK_SCHEDULER,
67 } g_all_pools_state = AllPoolsState::NONE_ACTIVE; 70 } g_all_pools_state = AllPoolsState::NONE_ACTIVE;
68 71
69 struct SequencedTask : public TrackingInfo { 72 struct SequencedTask : public TrackingInfo {
70 SequencedTask() 73 SequencedTask()
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 }; 366 };
364 367
365 enum CleanupState { 368 enum CleanupState {
366 CLEANUP_REQUESTED, 369 CLEANUP_REQUESTED,
367 CLEANUP_STARTING, 370 CLEANUP_STARTING,
368 CLEANUP_RUNNING, 371 CLEANUP_RUNNING,
369 CLEANUP_FINISHING, 372 CLEANUP_FINISHING,
370 CLEANUP_DONE, 373 CLEANUP_DONE,
371 }; 374 };
372 375
376 struct TaskRunnerAndShutdownBehavior {
377 scoped_refptr<TaskRunner> task_runner;
378 TaskShutdownBehavior shutdown_behavior;
379 };
380
381 bool RunsTasksOnCurrentThreadAssertSynchronized() const;
382
373 // Helper used by PostTask() to complete the work when redirection is on. 383 // Helper used by PostTask() to complete the work when redirection is on.
374 // Coalesce upon resolution of http://crbug.com/622400. 384 // Coalesce upon resolution of http://crbug.com/622400.
375 void PostTaskToTaskScheduler(const SequencedTask& sequenced); 385 void PostTaskToTaskScheduler(const SequencedTask& sequenced,
386 const TimeDelta& delay);
376 387
377 // Called from within the lock, this converts the given token name into a 388 // Called from within the lock, this converts the given token name into a
378 // token ID, creating a new one if necessary. 389 // token ID, creating a new one if necessary.
379 int LockedGetNamedTokenID(const std::string& name); 390 int LockedGetNamedTokenID(const std::string& name);
380 391
381 // Called from within the lock, this returns the next sequence task number. 392 // Called from within the lock, this returns the next sequence task number.
382 int64_t LockedGetNextSequenceTaskNumber(); 393 int64_t LockedGetNextSequenceTaskNumber();
383 394
384 // Gets new task. There are 3 cases depending on the return value: 395 // Gets new task. There are 3 cases depending on the return value:
385 // 396 //
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 535
525 // Members below are used for the experimental redirection to TaskScheduler. 536 // Members below are used for the experimental redirection to TaskScheduler.
526 // TODO(gab): Remove these if http://crbug.com/622400 fails 537 // TODO(gab): Remove these if http://crbug.com/622400 fails
527 // (SequencedWorkerPool will be phased out completely otherwise). 538 // (SequencedWorkerPool will be phased out completely otherwise).
528 539
529 // The TaskPriority to be used for SequencedWorkerPool tasks redirected to the 540 // The TaskPriority to be used for SequencedWorkerPool tasks redirected to the
530 // TaskScheduler as an experiment (unused otherwise). 541 // TaskScheduler as an experiment (unused otherwise).
531 const base::TaskPriority task_priority_; 542 const base::TaskPriority task_priority_;
532 543
533 // A map of SequenceToken IDs to TaskScheduler TaskRunners used to redirect 544 // A map of SequenceToken IDs to TaskScheduler TaskRunners used to redirect
534 // SequencedWorkerPool usage to the TaskScheduler. 545 // sequenced tasks to the TaskScheduler.
535 std::map<int, scoped_refptr<TaskRunner>> sequenced_task_runner_map_; 546 std::map<int, TaskRunnerAndShutdownBehavior> sequenced_task_runner_map_;
robliao 2016/08/27 00:28:59 Unrelated Optional: Should these be unordered_maps
fdoray 2016/08/29 15:07:11 Done.
547
548 // TaskScheduler TaskRunners to redirect unsequenced tasks to the
549 // TaskScheduler.
550 std::map<TaskShutdownBehavior, scoped_refptr<TaskRunner>>
551 unsequenced_task_runners_;
536 552
537 // A dummy TaskRunner obtained from TaskScheduler with the same TaskTraits as 553 // A dummy TaskRunner obtained from TaskScheduler with the same TaskTraits as
538 // used by this SequencedWorkerPool to query for RunsTasksOnCurrentThread(). 554 // used by this SequencedWorkerPool to query for RunsTasksOnCurrentThread().
539 // Mutable so it can be lazily instantiated from RunsTasksOnCurrentThread(). 555 // Mutable so it can be lazily instantiated from RunsTasksOnCurrentThread().
540 mutable scoped_refptr<TaskRunner> runs_tasks_on_verifier_; 556 mutable scoped_refptr<TaskRunner> runs_tasks_on_verifier_;
541 557
542 DISALLOW_COPY_AND_ASSIGN(Inner); 558 DISALLOW_COPY_AND_ASSIGN(Inner);
543 }; 559 };
544 560
545 // Worker definitions --------------------------------------------------------- 561 // Worker definitions ---------------------------------------------------------
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this))), 716 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this))),
701 TRACE_EVENT_FLAG_FLOW_OUT); 717 TRACE_EVENT_FLAG_FLOW_OUT);
702 718
703 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber(); 719 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber();
704 720
705 // Now that we have the lock, apply the named token rules. 721 // Now that we have the lock, apply the named token rules.
706 if (optional_token_name) 722 if (optional_token_name)
707 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name); 723 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name);
708 724
709 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { 725 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) {
710 PostTaskToTaskScheduler(sequenced); 726 PostTaskToTaskScheduler(sequenced, delay);
711 } else { 727 } else {
712 pending_tasks_.insert(sequenced); 728 pending_tasks_.insert(sequenced);
713 729
714 if (sequenced.shutdown_behavior == BLOCK_SHUTDOWN) 730 if (sequenced.shutdown_behavior == BLOCK_SHUTDOWN)
715 blocking_shutdown_pending_task_count_++; 731 blocking_shutdown_pending_task_count_++;
716 732
717 create_thread_id = PrepareToStartAdditionalThreadIfHelpful(); 733 create_thread_id = PrepareToStartAdditionalThreadIfHelpful();
718 } 734 }
719 } 735 }
720 736
(...skipping 16 matching lines...) Expand all
737 DCHECK_EQ(0, create_thread_id); 753 DCHECK_EQ(0, create_thread_id);
738 } else { 754 } else {
739 DCHECK(sequenced_task_runner_map_.empty()); 755 DCHECK(sequenced_task_runner_map_.empty());
740 } 756 }
741 } 757 }
742 #endif // DCHECK_IS_ON() 758 #endif // DCHECK_IS_ON()
743 759
744 return true; 760 return true;
745 } 761 }
746 762
763 bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThreadAssertSynchronized()
764 const {
765 lock_.AssertAcquired();
766 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) {
767 // TODO(fdoray): Add a special case for single-threaded pools.
768 if (!runs_tasks_on_verifier_) {
769 runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits(
770 TaskTraits().WithFileIO().WithPriority(task_priority_),
771 ExecutionMode::PARALLEL);
772 }
773 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread();
774 } else {
775 return ContainsKey(threads_, PlatformThread::CurrentId());
776 }
777 }
778
747 void SequencedWorkerPool::Inner::PostTaskToTaskScheduler( 779 void SequencedWorkerPool::Inner::PostTaskToTaskScheduler(
748 const SequencedTask& sequenced) { 780 const SequencedTask& sequenced,
781 const TimeDelta& delay) {
749 DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state); 782 DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state);
750 783
751 lock_.AssertAcquired(); 784 lock_.AssertAcquired();
752 785
753 // Confirm that the TaskScheduler's shutdown behaviors use the same 786 // Confirm that the TaskScheduler's shutdown behaviors use the same
754 // underlying values as SequencedWorkerPool. 787 // underlying values as SequencedWorkerPool.
755 static_assert( 788 static_assert(
756 static_cast<int>(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) == 789 static_cast<int>(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) ==
757 static_cast<int>(CONTINUE_ON_SHUTDOWN), 790 static_cast<int>(CONTINUE_ON_SHUTDOWN),
758 "TaskShutdownBehavior and WorkerShutdown enum mismatch for " 791 "TaskShutdownBehavior and WorkerShutdown enum mismatch for "
759 "CONTINUE_ON_SHUTDOWN."); 792 "CONTINUE_ON_SHUTDOWN.");
760 static_assert(static_cast<int>(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) == 793 static_assert(static_cast<int>(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) ==
761 static_cast<int>(SKIP_ON_SHUTDOWN), 794 static_cast<int>(SKIP_ON_SHUTDOWN),
762 "TaskShutdownBehavior and WorkerShutdown enum mismatch for " 795 "TaskShutdownBehavior and WorkerShutdown enum mismatch for "
763 "SKIP_ON_SHUTDOWN."); 796 "SKIP_ON_SHUTDOWN.");
764 static_assert(static_cast<int>(TaskShutdownBehavior::BLOCK_SHUTDOWN) == 797 static_assert(static_cast<int>(TaskShutdownBehavior::BLOCK_SHUTDOWN) ==
765 static_cast<int>(BLOCK_SHUTDOWN), 798 static_cast<int>(BLOCK_SHUTDOWN),
766 "TaskShutdownBehavior and WorkerShutdown enum mismatch for " 799 "TaskShutdownBehavior and WorkerShutdown enum mismatch for "
767 "BLOCK_SHUTDOWN."); 800 "BLOCK_SHUTDOWN.");
768 801
769 const TaskShutdownBehavior task_shutdown_behavior = 802 const TaskShutdownBehavior task_shutdown_behavior =
770 static_cast<TaskShutdownBehavior>(sequenced.shutdown_behavior); 803 static_cast<TaskShutdownBehavior>(sequenced.shutdown_behavior);
771 const TaskTraits pool_traits = 804 const TaskTraits pool_traits =
772 TaskTraits() 805 TaskTraits()
773 .WithFileIO() 806 .WithFileIO()
774 .WithPriority(task_priority_) 807 .WithPriority(task_priority_)
775 .WithShutdownBehavior(task_shutdown_behavior); 808 .WithShutdownBehavior(task_shutdown_behavior);
776 809
777 // Find or create the TaskScheduler TaskRunner to redirect this task to if 810 // Find or create the TaskScheduler TaskRunner to redirect this task to.
778 // it is posted to a specific sequence. 811 scoped_refptr<TaskRunner> task_runner;
779 scoped_refptr<TaskRunner>* sequenced_task_runner = nullptr;
780 if (sequenced.sequence_token_id) { 812 if (sequenced.sequence_token_id) {
781 sequenced_task_runner = 813 TaskRunnerAndShutdownBehavior& task_runner_and_shutdown_behavior =
782 &sequenced_task_runner_map_[sequenced.sequence_token_id]; 814 sequenced_task_runner_map_[sequenced.sequence_token_id];
783 if (!*sequenced_task_runner) { 815 if (!task_runner_and_shutdown_behavior.task_runner) {
784 const ExecutionMode execution_mode = 816 const ExecutionMode execution_mode =
785 max_threads_ == 1U ? ExecutionMode::SINGLE_THREADED 817 max_threads_ == 1U ? ExecutionMode::SINGLE_THREADED
786 : ExecutionMode::SEQUENCED; 818 : ExecutionMode::SEQUENCED;
787 *sequenced_task_runner = 819 task_runner_and_shutdown_behavior.task_runner =
820 CreateTaskRunnerWithTraits(pool_traits, execution_mode);
821 task_runner_and_shutdown_behavior.shutdown_behavior =
822 task_shutdown_behavior;
823 }
824
825 // Posting tasks to the same sequence with different shutdown behaviors
826 // isn't supported by the TaskScheduler.
827 DCHECK_EQ(task_shutdown_behavior,
828 task_runner_and_shutdown_behavior.shutdown_behavior);
829
830 task_runner = task_runner_and_shutdown_behavior.task_runner;
831 } else {
832 scoped_refptr<TaskRunner>& task_runner_for_shutdown_behavior_ref =
833 unsequenced_task_runners_[task_shutdown_behavior];
834 if (!task_runner_for_shutdown_behavior_ref) {
835 const ExecutionMode execution_mode = max_threads_ == 1U
836 ? ExecutionMode::SINGLE_THREADED
837 : ExecutionMode::PARALLEL;
838 task_runner_for_shutdown_behavior_ref =
788 CreateTaskRunnerWithTraits(pool_traits, execution_mode); 839 CreateTaskRunnerWithTraits(pool_traits, execution_mode);
789 } 840 }
841
842 task_runner = task_runner_for_shutdown_behavior_ref;
790 } 843 }
791 844
792 if (sequenced_task_runner) { 845 // Single-threaded pools can legitimatelly assume thread affinity. Disallow
793 (*sequenced_task_runner) 846 // posting tasks with different sequence tokens or shutdown behaviors in such
794 ->PostTask(sequenced.posted_from, sequenced.task); 847 // pools since the TaskScheduler can't force them to run on the same thread.
795 } else { 848 DCHECK(max_threads_ > 1 ||
796 // PostTaskWithTraits() posts a task with PARALLEL semantics. There are 849 (unsequenced_task_runners_.size() +
797 // however a few pools that use only one thread and therefore can currently 850 sequenced_task_runner_map_.size()) == 1);
798 // legitimatelly assume thread affinity despite using SequencedWorkerPool. 851
799 // Such pools typically only give access to their TaskRunner which will be 852 task_runner->PostDelayedTask(sequenced.posted_from, sequenced.task, delay);
800 // SINGLE_THREADED per nature of the pool having only one thread but this
801 // DCHECK ensures no such pools use SequencedWorkerPool::PostTask()
802 // directly.
803 DCHECK_GT(max_threads_, 1U);
804 base::PostTaskWithTraits(sequenced.posted_from, pool_traits,
805 sequenced.task);
806 }
807 } 853 }
808 854
809 bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThread() const { 855 bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThread() const {
810 AutoLock lock(lock_); 856 AutoLock lock(lock_);
811 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { 857 return RunsTasksOnCurrentThreadAssertSynchronized();
812 if (!runs_tasks_on_verifier_) {
813 runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits(
814 TaskTraits().WithFileIO().WithPriority(task_priority_),
815 ExecutionMode::PARALLEL);
816 }
817 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread();
818 } else {
819 return ContainsKey(threads_, PlatformThread::CurrentId());
820 }
821 } 858 }
822 859
823 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread( 860 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread(
824 SequenceToken sequence_token) const { 861 SequenceToken sequence_token) const {
825 AutoLock lock(lock_); 862 AutoLock lock(lock_);
826 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { 863 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) {
864 if (!sequence_token.IsValid())
865 return RunsTasksOnCurrentThreadAssertSynchronized();
866
827 // TODO(gab): This currently only verifies that the current thread is a 867 // TODO(gab): This currently only verifies that the current thread is a
828 // thread on which a task bound to |sequence_token| *could* run, but it 868 // thread on which a task bound to |sequence_token| *could* run, but it
829 // doesn't verify that the current is *currently running* a task bound to 869 // doesn't verify that the current is *currently running* a task bound to
830 // |sequence_token|. 870 // |sequence_token|.
831 const auto sequenced_task_runner_it = 871 const auto sequenced_task_runner_it =
832 sequenced_task_runner_map_.find(sequence_token.id_); 872 sequenced_task_runner_map_.find(sequence_token.id_);
833 return sequenced_task_runner_it != sequenced_task_runner_map_.end() && 873 return sequenced_task_runner_it != sequenced_task_runner_map_.end() &&
834 sequenced_task_runner_it->second->RunsTasksOnCurrentThread(); 874 sequenced_task_runner_it->second.task_runner
875 ->RunsTasksOnCurrentThread();
835 } else { 876 } else {
836 ThreadMap::const_iterator found = 877 ThreadMap::const_iterator found =
837 threads_.find(PlatformThread::CurrentId()); 878 threads_.find(PlatformThread::CurrentId());
838 if (found == threads_.end()) 879 if (found == threads_.end())
839 return false; 880 return false;
840 return found->second->is_processing_task() && 881 return found->second->is_processing_task() &&
841 sequence_token.Equals(found->second->task_sequence_token()); 882 sequence_token.Equals(found->second->task_sequence_token());
842 } 883 }
843 } 884 }
844 885
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 scoped_refptr<SequencedWorkerPool> 1412 scoped_refptr<SequencedWorkerPool>
1372 SequencedWorkerPool::GetWorkerPoolForCurrentThread() { 1413 SequencedWorkerPool::GetWorkerPoolForCurrentThread() {
1373 Worker* worker = Worker::GetForCurrentThread(); 1414 Worker* worker = Worker::GetForCurrentThread();
1374 if (!worker) 1415 if (!worker)
1375 return nullptr; 1416 return nullptr;
1376 1417
1377 return worker->worker_pool(); 1418 return worker->worker_pool();
1378 } 1419 }
1379 1420
1380 // static 1421 // static
1381 void SequencedWorkerPool:: 1422 void SequencedWorkerPool::RedirectToTaskSchedulerForProcess() {
1382 RedirectSequencedWorkerPoolsToTaskSchedulerForProcess() {
1383 DCHECK(TaskScheduler::GetInstance()); 1423 DCHECK(TaskScheduler::GetInstance());
1384 // Hitting this DCHECK indicates that a task was posted to a 1424 // Hitting this DCHECK indicates that a task was posted to a
1385 // SequencedWorkerPool before the TaskScheduler was initialized and 1425 // SequencedWorkerPool before the TaskScheduler was initialized and
1386 // redirected, posting task to SequencedWorkerPools needs to at least be 1426 // redirected, posting task to SequencedWorkerPools needs to at least be
1387 // delayed until after that point. 1427 // delayed until after that point.
1388 DCHECK_EQ(AllPoolsState::NONE_ACTIVE, g_all_pools_state); 1428 DCHECK_EQ(AllPoolsState::NONE_ACTIVE, g_all_pools_state);
1389 g_all_pools_state = AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER; 1429 g_all_pools_state = AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER;
1390 } 1430 }
1391 1431
1432 // static
1433 void SequencedWorkerPool::ResetRedirectToTaskSchedulerForProcessForTesting() {
1434 g_all_pools_state = AllPoolsState::NONE_ACTIVE;
1435 }
1436
1392 SequencedWorkerPool::SequencedWorkerPool(size_t max_threads, 1437 SequencedWorkerPool::SequencedWorkerPool(size_t max_threads,
1393 const std::string& thread_name_prefix, 1438 const std::string& thread_name_prefix,
1394 base::TaskPriority task_priority) 1439 base::TaskPriority task_priority)
1395 : constructor_task_runner_(ThreadTaskRunnerHandle::Get()), 1440 : constructor_task_runner_(ThreadTaskRunnerHandle::Get()),
1396 inner_(new Inner(this, 1441 inner_(new Inner(this,
1397 max_threads, 1442 max_threads,
1398 thread_name_prefix, 1443 thread_name_prefix,
1399 task_priority, 1444 task_priority,
1400 NULL)) {} 1445 NULL)) {}
1401 1446
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const { 1566 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const {
1522 return inner_->RunsTasksOnCurrentThread(); 1567 return inner_->RunsTasksOnCurrentThread();
1523 } 1568 }
1524 1569
1525 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( 1570 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread(
1526 SequenceToken sequence_token) const { 1571 SequenceToken sequence_token) const {
1527 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); 1572 return inner_->IsRunningSequenceOnCurrentThread(sequence_token);
1528 } 1573 }
1529 1574
1530 void SequencedWorkerPool::FlushForTesting() { 1575 void SequencedWorkerPool::FlushForTesting() {
1576 DCHECK_NE(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state);
1531 inner_->CleanupForTesting(); 1577 inner_->CleanupForTesting();
1532 } 1578 }
1533 1579
1534 void SequencedWorkerPool::SignalHasWorkForTesting() { 1580 void SequencedWorkerPool::SignalHasWorkForTesting() {
1535 inner_->SignalHasWorkForTesting(); 1581 inner_->SignalHasWorkForTesting();
1536 } 1582 }
1537 1583
1538 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1584 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1539 DCHECK(constructor_task_runner_->BelongsToCurrentThread()); 1585 DCHECK(constructor_task_runner_->BelongsToCurrentThread());
1540 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1586 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1541 } 1587 }
1542 1588
1543 bool SequencedWorkerPool::IsShutdownInProgress() { 1589 bool SequencedWorkerPool::IsShutdownInProgress() {
1544 return inner_->IsShutdownInProgress(); 1590 return inner_->IsShutdownInProgress();
1545 } 1591 }
1546 1592
1547 } // namespace base 1593 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698