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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 const tracked_objects::Location& from_here, | 316 const tracked_objects::Location& from_here, |
317 const Closure& task, | 317 const Closure& task, |
318 WorkerShutdown shutdown_behavior); | 318 WorkerShutdown shutdown_behavior); |
319 | 319 |
320 // TaskRunner implementation. Forwards to PostDelayedWorkerTask(). | 320 // TaskRunner implementation. Forwards to PostDelayedWorkerTask(). |
321 bool PostDelayedTask(const tracked_objects::Location& from_here, | 321 bool PostDelayedTask(const tracked_objects::Location& from_here, |
322 const Closure& task, | 322 const Closure& task, |
323 TimeDelta delay) override; | 323 TimeDelta delay) override; |
324 bool RunsTasksOnCurrentThread() const override; | 324 bool RunsTasksOnCurrentThread() const override; |
325 | 325 |
326 // Returns true if the current thread is processing a task with the given | |
327 // sequence_token. | |
328 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; | |
329 | |
330 // Blocks until all pending tasks are complete. This should only be called in | 326 // Blocks until all pending tasks are complete. This should only be called in |
331 // unit tests when you want to validate something that should have happened. | 327 // unit tests when you want to validate something that should have happened. |
332 // This will not flush delayed tasks; delayed tasks get deleted. | 328 // This will not flush delayed tasks; delayed tasks get deleted. |
333 // | 329 // |
334 // Note that calling this will not prevent other threads from posting work to | 330 // Note that calling this will not prevent other threads from posting work to |
335 // the queue while the calling thread is waiting on Flush(). In this case, | 331 // the queue while the calling thread is waiting on Flush(). In this case, |
336 // Flush will return only when there's no more work in the queue. Normally, | 332 // Flush will return only when there's no more work in the queue. Normally, |
337 // this doesn't come up since in a test, all the work is being posted from | 333 // this doesn't come up since in a test, all the work is being posted from |
338 // the main thread. | 334 // the main thread. |
339 void FlushForTesting(); | 335 void FlushForTesting(); |
(...skipping 23 matching lines...) Expand all Loading... | |
363 | 359 |
364 protected: | 360 protected: |
365 ~SequencedWorkerPool() override; | 361 ~SequencedWorkerPool() override; |
366 | 362 |
367 void OnDestruct() const override; | 363 void OnDestruct() const override; |
368 | 364 |
369 private: | 365 private: |
370 friend class RefCountedThreadSafe<SequencedWorkerPool>; | 366 friend class RefCountedThreadSafe<SequencedWorkerPool>; |
371 friend class DeleteHelper<SequencedWorkerPool>; | 367 friend class DeleteHelper<SequencedWorkerPool>; |
372 | 368 |
369 class PoolSequencedTaskRunner; | |
danakj
2016/09/15 18:18:24
sort please
fdoray
2016/09/15 18:29:06
Done.
| |
373 class Inner; | 370 class Inner; |
374 class Worker; | 371 class Worker; |
375 | 372 |
373 // Returns true if the current thread is processing a task with the given | |
374 // sequence_token. | |
375 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; | |
376 | |
376 const scoped_refptr<SingleThreadTaskRunner> constructor_task_runner_; | 377 const scoped_refptr<SingleThreadTaskRunner> constructor_task_runner_; |
377 | 378 |
378 // Avoid pulling in too many headers by putting (almost) everything | 379 // Avoid pulling in too many headers by putting (almost) everything |
379 // into |inner_|. | 380 // into |inner_|. |
380 const std::unique_ptr<Inner> inner_; | 381 const std::unique_ptr<Inner> inner_; |
381 | 382 |
382 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 383 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
383 }; | 384 }; |
384 | 385 |
385 } // namespace base | 386 } // namespace base |
386 | 387 |
387 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 388 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
OLD | NEW |