OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_TASK_RUNNER_H_ | |
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_TASK_RUNNER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/callback_forward.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/sequenced_task_runner.h" | |
14 #include "base/threading/sequenced_worker_pool.h" | |
15 #include "base/time.h" | |
16 | |
17 namespace tracked_objects { | |
18 class Location; | |
19 } // namespace tracked_objects | |
20 | |
21 namespace base { | |
22 | |
23 // A SequencedTaskRunner which posts tasks to a SequencedWorkerPool with a | |
24 // fixed sequence token. | |
25 // | |
26 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). | |
27 class BASE_EXPORT SequencedWorkerPoolTaskRunner : public SequencedTaskRunner { | |
28 public: | |
29 SequencedWorkerPoolTaskRunner(const scoped_refptr<SequencedWorkerPool>& pool, | |
30 SequencedWorkerPool::SequenceToken token); | |
31 | |
32 // TaskRunner implementation | |
33 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | |
34 const Closure& task, | |
35 TimeDelta delay) OVERRIDE; | |
36 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | |
37 | |
38 // SequencedTaskRunner implementation | |
39 virtual bool PostNonNestableDelayedTask( | |
40 const tracked_objects::Location& from_here, | |
41 const Closure& task, | |
42 TimeDelta delay) OVERRIDE; | |
43 | |
44 private: | |
45 virtual ~SequencedWorkerPoolTaskRunner(); | |
46 | |
47 // Helper function for posting a delayed task. Asserts that the delay is | |
48 // zero because non-zero delays are not yet supported. | |
49 bool PostDelayedTaskAssertZeroDelay( | |
50 const tracked_objects::Location& from_here, | |
51 const Closure& task, | |
52 TimeDelta delay); | |
53 | |
54 const scoped_refptr<SequencedWorkerPool> pool_; | |
55 | |
56 const SequencedWorkerPool::SequenceToken token_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolTaskRunner); | |
59 }; | |
60 | |
61 } // namespace base | |
62 | |
63 #endif // BASE_THREADING_SEQUENCED_TASK_RUNNER_IMPL_H_ | |
OLD | NEW |