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

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

Issue 2241703002: Add an experiment to redirect SequencedWorkerPool tasks to TaskScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b3_delay_metrics_blocking
Patch Set: Split PostTask into helpers and add bug comments. Created 4 years, 4 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 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_H_
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cstddef> 10 #include <cstddef>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 static SequenceToken GetSequenceTokenForCurrentThread(); 165 static SequenceToken GetSequenceTokenForCurrentThread();
166 166
167 // Returns the SequencedWorkerPool that owns this thread, or null if the 167 // Returns the SequencedWorkerPool that owns this thread, or null if the
168 // current thread is not a SequencedWorkerPool worker thread. 168 // current thread is not a SequencedWorkerPool worker thread.
169 static scoped_refptr<SequencedWorkerPool> GetWorkerPoolForCurrentThread(); 169 static scoped_refptr<SequencedWorkerPool> GetWorkerPoolForCurrentThread();
170 170
171 // Returns a unique token that can be used to sequence tasks posted to 171 // Returns a unique token that can be used to sequence tasks posted to
172 // PostSequencedWorkerTask(). Valid tokens are always nonzero. 172 // PostSequencedWorkerTask(). Valid tokens are always nonzero.
173 static SequenceToken GetSequenceToken(); 173 static SequenceToken GetSequenceToken();
174 174
175 // Invoke this once on the main thread of a process, before any other threads
176 // are created and before any tasks are posted to that process'
177 // SequencedWorkerPools but after TaskScheduler was instantiated, to force all
178 // SequencedWorkerPools in that process to redirect their tasks to the
179 // TaskScheduler. Note: SequencedWorkerPool instances with |max_threads == 1|
180 // will be special cased to send all of their work as
181 // ExecutionMode::SINGLE_THREADED.
182 // TODO(gab): Remove this if http://crbug.com/622400 fails
183 // (SequencedWorkerPool will be phased out completely otherwise).
184 static void RedirectSequencedWorkerPoolsToTaskSchedulerForProcess();
185
175 // When constructing a SequencedWorkerPool, there must be a 186 // When constructing a SequencedWorkerPool, there must be a
176 // ThreadTaskRunnerHandle on the current thread unless you plan to 187 // ThreadTaskRunnerHandle on the current thread unless you plan to
177 // deliberately leak it. 188 // deliberately leak it.
178 189
179 // Pass the maximum number of threads (they will be lazily created as needed) 190 // Pass the maximum number of threads (they will be lazily created as needed)
180 // and a prefix for the thread name to aid in debugging. |task_priority| will 191 // and a prefix for the thread name to aid in debugging. |task_priority| will
181 // be used to hint base::TaskScheduler for an experiment in which all 192 // be used to hint base::TaskScheduler for an experiment in which all
182 // SequencedWorkerPool tasks will be redirected to it in processes where a 193 // SequencedWorkerPool tasks will be redirected to it in processes where a
183 // base::TaskScheduler was instantiated. 194 // base::TaskScheduler was instantiated.
184 SequencedWorkerPool(size_t max_threads, 195 SequencedWorkerPool(size_t max_threads,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Avoid pulling in too many headers by putting (almost) everything 385 // Avoid pulling in too many headers by putting (almost) everything
375 // into |inner_|. 386 // into |inner_|.
376 const std::unique_ptr<Inner> inner_; 387 const std::unique_ptr<Inner> inner_;
377 388
378 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); 389 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool);
379 }; 390 };
380 391
381 } // namespace base 392 } // namespace base
382 393
383 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 394 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.cc » ('j') | base/threading/sequenced_worker_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698