diff options
Diffstat (limited to 'base/thread.h')
-rw-r--r-- | base/thread.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/base/thread.h b/base/thread.h index 88bff7b..b5a87eb 100644 --- a/base/thread.h +++ b/base/thread.h @@ -8,6 +8,7 @@ #include <string> #include "base/message_loop.h" +#include "base/message_loop_proxy.h" #include "base/platform_thread.h" namespace base { @@ -104,6 +105,16 @@ class Thread : PlatformThread::Delegate { // MessageLoop* message_loop() const { return message_loop_; } + // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's + // PostTask methods to execute code on the thread. This only returns + // 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. + // TODO(sanjeevr): Look into merging MessageLoop and MessageLoopProxy. + scoped_refptr<MessageLoopProxy> message_loop_proxy() { + return message_loop_proxy_; + } + // Set the name of this thread (for display in debugger too). const std::string &thread_name() { return name_; } @@ -162,6 +173,10 @@ class Thread : PlatformThread::Delegate { // by the created thread. MessageLoop* message_loop_; + // A MessageLoopProxy implementation that targets this thread. This can + // outlive the thread. + scoped_refptr<MessageLoopProxy> message_loop_proxy_; + // Our thread's ID. PlatformThreadId thread_id_; |