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