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_SINGLE_THREAD_TASK_RUNNER_H_ | 5 #ifndef BASE_SINGLE_THREAD_TASK_RUNNER_H_ |
6 #define BASE_SINGLE_THREAD_TASK_RUNNER_H_ | 6 #define BASE_SINGLE_THREAD_TASK_RUNNER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 // A SingleThreadTaskRunner is a SequencedTaskRunner with one more | 14 // A SingleThreadTaskRunner is a SequencedTaskRunner with one more |
15 // guarantee; namely, that all tasks are run on a single dedicated | 15 // guarantee; namely, that all tasks are run on a single dedicated |
16 // thread. Most use cases require only a SequencedTaskRunner, unless | 16 // thread. Most use cases require only a SequencedTaskRunner, unless |
17 // there is a specific need to run tasks on only a single dedicated. | 17 // there is a specific need to run tasks on only a single dedicated. |
18 // | 18 // |
19 // Some theoretical implementations of SingleThreadTaskRunner: | 19 // Some theoretical implementations of SingleThreadTaskRunner: |
20 // | 20 // |
21 // - A SingleThreadTaskRunner that uses a single worker thread to | 21 // - A SingleThreadTaskRunner that uses a single worker thread to |
22 // run posted tasks (i.e., a message loop). | 22 // run posted tasks (i.e., a message loop). |
23 // | 23 // |
24 // - A SingleThreadTaskRunner that stores the list of posted tasks | 24 // - A SingleThreadTaskRunner that stores the list of posted tasks |
25 // and has a method Run() that runs each runnable task in FIFO | 25 // and has a method Run() that runs each runnable task in FIFO |
26 // order that must be run only from the thread the | 26 // order that must be run only from the thread the |
27 // SingleThreadTaskRunner was created on. | 27 // SingleThreadTaskRunner was created on. |
28 class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { | 28 class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { |
29 public: | 29 public: |
30 // A more explicit alias to RunsTasksOnCurrentThread(). | 30 // A more explicit alias to RunsTasksOnCurrentThread(). |
31 bool BelongsToCurrentThread() const { | 31 bool BelongsToCurrentThread() const { |
32 return RunsTasksOnCurrentThread(); | 32 return RunsTasksOnCurrentThread(); |
33 } | 33 } |
| 34 |
| 35 protected: |
| 36 virtual ~SingleThreadTaskRunner() {} |
34 }; | 37 }; |
35 | 38 |
36 } // namespace base | 39 } // namespace base |
37 | 40 |
38 #endif // BASE_SERIAL_TASK_RUNNER_H_ | 41 #endif // BASE_SERIAL_TASK_RUNNER_H_ |
OLD | NEW |