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

Unified Diff: base/threading/thread.h

Issue 389653005: Introduce task_runner() accessors for both base::Thread and base::MessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop header Created 6 years, 5 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/message_loop/message_loop.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread.h
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 9d446dd7feb01a3e9b23c5cd9c369890df05cd85..6f0dabcf8d0adf5159e9370c82574c7d74927ccc 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -143,10 +143,22 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// non-NULL after a successful call to Start. After Stop has been called,
// this will return NULL. Callers can hold on to this even after the thread
// is gone.
+ //
+ // Note: This method is deprecated. Callers should call task_runner() instead
+ // and use the TaskRunner interfaces for safely interfacing with the Thread.
scoped_refptr<MessageLoopProxy> message_loop_proxy() const {
return message_loop_ ? message_loop_->message_loop_proxy() : NULL;
}
+ // Returns a TaskRunner for this thread. Use the TaskRunner's PostTask
+ // methods to execute code on the thread. This only returns non-NULL after
awong 2014/07/11 20:23:18 How about "Returns NULL if thread is not running?
+ // a successfull call to Start. After Stop has been called, this will
+ // return NULL. Callers can hold on to this even after the thread is gone;
+ // in this situation, attempts to PostTask() will fail.
+ scoped_refptr<SingleThreadTaskRunner> task_runner() const {
+ return message_loop_proxy();
+ }
+
// Returns the name of this thread (for display in debugger too).
const std::string& thread_name() const { return name_; }
« no previous file with comments | « base/message_loop/message_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698