michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_SINGLE_THREAD_TASK_RUNNER_H_ michael@0: #define BASE_SINGLE_THREAD_TASK_RUNNER_H_ michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/sequenced_task_runner.h" michael@0: michael@0: namespace base { michael@0: michael@0: // A SingleThreadTaskRunner is a SequencedTaskRunner with one more michael@0: // guarantee; namely, that all tasks are run on a single dedicated michael@0: // thread. Most use cases require only a SequencedTaskRunner, unless michael@0: // there is a specific need to run tasks on only a single thread. michael@0: // michael@0: // SingleThreadTaskRunner implementations might: michael@0: // - Post tasks to an existing thread's MessageLoop (see MessageLoopProxy). michael@0: // - Create their own worker thread and MessageLoop to post tasks to. michael@0: // - Add tasks to a FIFO and signal to a non-MessageLoop thread for them to michael@0: // be processed. This allows TaskRunner-oriented code run on threads michael@0: // running other kinds of message loop, e.g. Jingle threads. michael@0: class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { michael@0: public: michael@0: // A more explicit alias to RunsTasksOnCurrentThread(). michael@0: bool BelongsToCurrentThread() const { michael@0: return RunsTasksOnCurrentThread(); michael@0: } michael@0: michael@0: protected: michael@0: virtual ~SingleThreadTaskRunner() {} michael@0: }; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_SINGLE_THREAD_TASK_RUNNER_H_