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

Unified Diff: base/threading/thread_task_runner_handle.h

Issue 2042383004: Introduce TaskRunnerHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comments Created 4 years, 6 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
« no previous file with comments | « base/threading/task_runner_handle_unittest.cc ('k') | base/threading/thread_task_runner_handle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread_task_runner_handle.h
diff --git a/base/threading/thread_task_runner_handle.h b/base/threading/thread_task_runner_handle.h
index c8e58935f0977259349857bf91d71c63bf734567..7e389fb9a49df9ba6b607bd8da59e927960912a1 100644
--- a/base/threading/thread_task_runner_handle.h
+++ b/base/threading/thread_task_runner_handle.h
@@ -9,31 +9,34 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
+#include "base/threading/task_runner_handle.h"
namespace base {
-// ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner
-// in thread-local storage. Callers can then retrieve the TaskRunner
-// for the current thread by calling ThreadTaskRunnerHandle::Get().
-// At most one TaskRunner may be bound to each thread at a time.
-// Prefer SequenceTaskRunnerHandle to this unless thread affinity is required.
+// Deprecated, see below for specifics.
class BASE_EXPORT ThreadTaskRunnerHandle {
public:
- // Gets the SingleThreadTaskRunner for the current thread.
- static scoped_refptr<SingleThreadTaskRunner> Get();
-
- // Returns true if the SingleThreadTaskRunner is already created for
- // the current thread.
- static bool IsSet();
-
- // Binds |task_runner| to the current thread. |task_runner| must belong
- // to the current thread for this to succeed.
+ // Deprecated, use TaskRunnerHandle::Get.*() instead.
+ // Note: There will not be an automated ThreadTaskRunnerHandle::Get() =>
+ // TaskRunnerHandle::GetSingleThreaded() change. ThreadTaskRunnerHandle::Get()
+ // callsites should instead be examined one-by-one and given the right
+ // semantics for their use case (i.e. don't use GetSingleThreaded() unless
+ // truly thread-affine).
+ static scoped_refptr<SingleThreadTaskRunner> Get() {
+ return TaskRunnerHandle::GetSingleThreaded();
+ }
+
+ // Deprecated, use TaskRunnerHandle::HasSingleThreadTaskScope() instead.
+ static bool IsSet() { return TaskRunnerHandle::HasSingleThreadTaskScope(); }
+
+ // Binds |task_runner| to the current thread. Deprecated, use
+ // TaskRunnerHandle::SingleThreadTaskScope instead.
explicit ThreadTaskRunnerHandle(
scoped_refptr<SingleThreadTaskRunner> task_runner);
~ThreadTaskRunnerHandle();
private:
- scoped_refptr<SingleThreadTaskRunner> task_runner_;
+ TaskRunnerHandle::SingleThreadTaskScope task_scope_;
DISALLOW_COPY_AND_ASSIGN(ThreadTaskRunnerHandle);
};
« no previous file with comments | « base/threading/task_runner_handle_unittest.cc ('k') | base/threading/thread_task_runner_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698