blob: a9ba6fd8fcfc0357ba677ecad0afc6a2e8c57a53 [file] [log] [blame]
[email protected]6b28d942012-02-15 01:43:191// 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_
[email protected]6b28d942012-02-15 01:43:197
8#include "base/base_export.h"
9#include "base/sequenced_task_runner.h"
10
11namespace base {
12
13// A SingleThreadTaskRunner is a SequencedTaskRunner with one more
14// guarantee; namely, that all tasks are run on a single dedicated
15// thread. Most use cases require only a SequencedTaskRunner, unless
16// there is a specific need to run tasks on only a single dedicated.
17//
18// Some theoretical implementations of SingleThreadTaskRunner:
19//
20// - A SingleThreadTaskRunner that uses a single worker thread to
21// run posted tasks (i.e., a message loop).
22//
23// - A SingleThreadTaskRunner that stores the list of posted tasks
24// and has a method Run() that runs each runnable task in FIFO
25// order that must be run only from the thread the
26// SingleThreadTaskRunner was created on.
27class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner {
[email protected]f2ebbf062012-04-06 03:14:3028 public:
[email protected]6b28d942012-02-15 01:43:1929 // A more explicit alias to RunsTasksOnCurrentThread().
30 bool BelongsToCurrentThread() const {
31 return RunsTasksOnCurrentThread();
32 }
[email protected]f2ebbf062012-04-06 03:14:3033
34 protected:
35 virtual ~SingleThreadTaskRunner() {}
[email protected]6b28d942012-02-15 01:43:1936};
37
38} // namespace base
39
[email protected]a8582b12012-12-19 22:18:2940#endif // BASE_SINGLE_THREAD_TASK_RUNNER_H_