blob: c87e5f7ff1438c4599b18d5c146b2de89c9476ef [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_
7#pragma once
8
9#include "base/base_export.h"
10#include "base/sequenced_task_runner.h"
11
12namespace 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.
28class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner {
[email protected]f2ebbf062012-04-06 03:14:3029 public:
[email protected]6b28d942012-02-15 01:43:1930 // A more explicit alias to RunsTasksOnCurrentThread().
31 bool BelongsToCurrentThread() const {
32 return RunsTasksOnCurrentThread();
33 }
[email protected]f2ebbf062012-04-06 03:14:3034
35 protected:
36 virtual ~SingleThreadTaskRunner() {}
[email protected]6b28d942012-02-15 01:43:1937};
38
39} // namespace base
40
41#endif // BASE_SERIAL_TASK_RUNNER_H_