OLD | NEW |
---|---|
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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 ExecutionMode::PARALLEL); | 872 ExecutionMode::PARALLEL); |
873 } | 873 } |
874 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread(); | 874 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread(); |
875 } else { | 875 } else { |
876 return ContainsKey(threads_, PlatformThread::CurrentId()); | 876 return ContainsKey(threads_, PlatformThread::CurrentId()); |
877 } | 877 } |
878 } | 878 } |
879 | 879 |
880 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread( | 880 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread( |
881 SequenceToken sequence_token) const { | 881 SequenceToken sequence_token) const { |
882 DCHECK(sequence_token.IsValid()); | |
fdoray
2016/09/15 15:57:13
This is always called from PoolSequencedTaskRunner
| |
883 | |
882 AutoLock lock(lock_); | 884 AutoLock lock(lock_); |
885 | |
883 if (subtle::NoBarrier_Load(&g_all_pools_state) == | 886 if (subtle::NoBarrier_Load(&g_all_pools_state) == |
884 AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { | 887 AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { |
885 // TODO(gab): This currently only verifies that the current thread is a | |
danakj
2016/09/15 18:31:09
Isn't SequencedWorkerPool::Inner::RunsTasksOnCurre
fdoray
2016/09/15 18:39:23
|sequenced_task_runner_map_| contains TaskSchedule
danakj
2016/09/15 18:41:26
Thanks for the context! LGTM
| |
886 // thread on which a task bound to |sequence_token| *could* run, but it | |
887 // doesn't verify that the current is *currently running* a task bound to | |
888 // |sequence_token|. | |
889 const auto sequenced_task_runner_it = | 888 const auto sequenced_task_runner_it = |
890 sequenced_task_runner_map_.find(sequence_token.id_); | 889 sequenced_task_runner_map_.find(sequence_token.id_); |
891 return sequenced_task_runner_it != sequenced_task_runner_map_.end() && | 890 return sequenced_task_runner_it != sequenced_task_runner_map_.end() && |
892 sequenced_task_runner_it->second->RunsTasksOnCurrentThread(); | 891 sequenced_task_runner_it->second->RunsTasksOnCurrentThread(); |
893 } else { | 892 } else { |
894 ThreadMap::const_iterator found = | 893 ThreadMap::const_iterator found = |
895 threads_.find(PlatformThread::CurrentId()); | 894 threads_.find(PlatformThread::CurrentId()); |
896 if (found == threads_.end()) | 895 return found != threads_.end() && found->second->is_processing_task() && |
897 return false; | |
898 return found->second->is_processing_task() && | |
899 sequence_token.Equals(found->second->task_sequence_token()); | 896 sequence_token.Equals(found->second->task_sequence_token()); |
900 } | 897 } |
901 } | 898 } |
902 | 899 |
903 // See https://code.google.com/p/chromium/issues/detail?id=168415 | 900 // See https://code.google.com/p/chromium/issues/detail?id=168415 |
904 void SequencedWorkerPool::Inner::CleanupForTesting() { | 901 void SequencedWorkerPool::Inner::CleanupForTesting() { |
905 DCHECK(!RunsTasksOnCurrentThread()); | 902 DCHECK(!RunsTasksOnCurrentThread()); |
906 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 903 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
907 AutoLock lock(lock_); | 904 AutoLock lock(lock_); |
908 CHECK_EQ(CLEANUP_DONE, cleanup_state_); | 905 CHECK_EQ(CLEANUP_DONE, cleanup_state_); |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1611 bool SequencedWorkerPool::IsShutdownInProgress() { | 1608 bool SequencedWorkerPool::IsShutdownInProgress() { |
1612 return inner_->IsShutdownInProgress(); | 1609 return inner_->IsShutdownInProgress(); |
1613 } | 1610 } |
1614 | 1611 |
1615 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( | 1612 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( |
1616 SequenceToken sequence_token) const { | 1613 SequenceToken sequence_token) const { |
1617 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); | 1614 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); |
1618 } | 1615 } |
1619 | 1616 |
1620 } // namespace base | 1617 } // namespace base |
OLD | NEW |