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 #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 Loading... | |
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 | |
brettw
2016/08/12 19:30:00
This should have a reference to a bug to remove it
gab
2016/08/12 23:27:46
Done.
| |
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 static void RedirectSequencedWorkerPoolsToTaskSchedulerForProcess(); | |
183 | |
175 // When constructing a SequencedWorkerPool, there must be a | 184 // When constructing a SequencedWorkerPool, there must be a |
176 // ThreadTaskRunnerHandle on the current thread unless you plan to | 185 // ThreadTaskRunnerHandle on the current thread unless you plan to |
177 // deliberately leak it. | 186 // deliberately leak it. |
178 | 187 |
179 // Pass the maximum number of threads (they will be lazily created as needed) | 188 // 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 | 189 // 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 | 190 // be used to hint base::TaskScheduler for an experiment in which all |
182 // SequencedWorkerPool tasks will be redirected to it in processes where a | 191 // SequencedWorkerPool tasks will be redirected to it in processes where a |
183 // base::TaskScheduler was instantiated. | 192 // base::TaskScheduler was instantiated. |
184 SequencedWorkerPool(size_t max_threads, | 193 SequencedWorkerPool(size_t max_threads, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 // Avoid pulling in too many headers by putting (almost) everything | 383 // Avoid pulling in too many headers by putting (almost) everything |
375 // into |inner_|. | 384 // into |inner_|. |
376 const std::unique_ptr<Inner> inner_; | 385 const std::unique_ptr<Inner> inner_; |
377 | 386 |
378 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 387 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
379 }; | 388 }; |
380 | 389 |
381 } // namespace base | 390 } // namespace base |
382 | 391 |
383 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 392 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
OLD | NEW |