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 run on a single dedicated |
| 16 // thread. Most use cases require only a SequencedTaskRunner, unless |
| 17 // there is a specific need to run tasks on only a single dedicated. |
| 18 // |
| 19 // Some theoretical implementations of SingleThreadTaskRunner: |
| 20 // |
| 21 // - A SingleThreadTaskRunner that uses a single worker thread to |
| 22 // run posted tasks (i.e., a message loop). |
| 23 // |
| 24 // - A SingleThreadTaskRunner that stores the list of posted tasks |
| 25 // and has a method Run() that runs each runnable task in FIFO |
| 26 // order that must be run only from the thread the |
| 27 // SingleThreadTaskRunner was created on. |
| 28 class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { |
| 29 public: |
| 30 // A more explicit alias to RunsTasksOnCurrentThread(). |
| 31 bool BelongsToCurrentThread() const { |
| 32 return RunsTasksOnCurrentThread(); |
| 33 } |
| 34 }; |
| 35 |
| 36 } // namespace base |
| 37 |
| 38 #endif // BASE_SERIAL_TASK_RUNNER_H_ |
OLD | NEW |