Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2352)

Unified Diff: base/single_thread_executor.h

Issue 9169037: Make new TaskRunner, SequencedTaskRunner, and SingleThreadTaskRunner interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win build Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/single_thread_executor.h
diff --git a/base/single_thread_executor.h b/base/single_thread_executor.h
new file mode 100644
index 0000000000000000000000000000000000000000..2a63768d9bf3cd6a2461ae9522ca87e5239ed67a
--- /dev/null
+++ b/base/single_thread_executor.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_SINGLE_THREAD_EXECUTOR_H_
+#define BASE_SINGLE_THREAD_EXECUTOR_H_
+#pragma once
+
+#include "base/base_export.h"
+#include "base/serial_executor.h"
+
+namespace base {
+
+// A SingleThreadExecutor is a SerialExecutor with one more guarantee;
+// namely, that all tasks are executed on a single specific thread.
+//
+// Some theoretical implementations of SingleThreadExecutor:
+//
+// - A SingleThreadExecutor that uses a single worker thread to run
+// submitted tasks (i.e., a message loop).
+//
+// - A SingleThreadExecutor that stores the list of submitted tasks
+// and has a method Run() that executes each runnable task in FIFO
+// order that must be run only from the thread the
+// SingleThreadExecutor was created on.
+class BASE_EXPORT SingleThreadExecutor : public SerialExecutor {
+public:
+ // A more explicit alias to MayRunTasksOnCurrentThread().
+ bool BelongsToCurrentThread() const {
+ return MayRunTasksOnCurrentThread();
+ }
+};
+
+} // namespace base
+
+#endif // BASE_SERIAL_EXECUTOR_H_

Powered by Google App Engine
This is Rietveld 408576698