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

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl.cc

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/process_unittest.cc ('k') | base/task_scheduler/scheduler_worker_pool_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.cc b/base/task_scheduler/scheduler_worker_pool_impl.cc
index c9c72a2ee84f0a167fe677e98b3a0fdfaf24d4be..155f42dc132051ef24e91d27d8a4e512450a664d 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl.cc
@@ -41,10 +41,6 @@ constexpr char kNumTasksBetweenWaitsHistogramPrefix[] =
"TaskScheduler.NumTasksBetweenWaits.";
constexpr char kTaskLatencyHistogramPrefix[] = "TaskScheduler.TaskLatency.";
-// SchedulerWorker that owns the current thread, if any.
-LazyInstance<ThreadLocalPointer<const SchedulerWorker>>::Leaky
- tls_current_worker = LAZY_INSTANCE_INITIALIZER;
-
// SchedulerWorkerPool that owns the current thread, if any.
LazyInstance<ThreadLocalPointer<const SchedulerWorkerPool>>::Leaky
tls_current_worker_pool = LAZY_INSTANCE_INITIALIZER;
@@ -201,7 +197,10 @@ class SchedulerWorkerPoolImpl::SchedulerSingleThreadTaskRunner :
}
bool RunsTasksOnCurrentThread() const override {
- return tls_current_worker.Get().Get() == worker_;
+ // Even though this is a SingleThreadTaskRunner, test the actual sequence
+ // instead of the assigned worker so that another task randomly assigned
+ // to the same worker doesn't return true by happenstance.
+ return sequence_->token() == SequenceToken::GetForCurrentThread();
}
private:
@@ -505,9 +504,7 @@ void SchedulerWorkerPoolImpl::SchedulerWorkerDelegateImpl::OnMainEntry(
PlatformThread::SetName(
StringPrintf("TaskScheduler%sWorker%d", outer_->name_.c_str(), index_));
- DCHECK(!tls_current_worker.Get().Get());
DCHECK(!tls_current_worker_pool.Get().Get());
- tls_current_worker.Get().Set(worker);
tls_current_worker_pool.Get().Set(outer_);
// New threads haven't run GetWork() yet, so reset the |idle_start_time_|.
« no previous file with comments | « base/process/process_unittest.cc ('k') | base/task_scheduler/scheduler_worker_pool_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698