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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/message_loop/message_loop.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_THREADING_THREAD_H_ 5 #ifndef BASE_THREADING_THREAD_H_
6 #define BASE_THREADING_THREAD_H_ 6 #define BASE_THREADING_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // NOTE: You must not call this MessageLoop's Quit method directly. Use 136 // NOTE: You must not call this MessageLoop's Quit method directly. Use
137 // the Thread's Stop method instead. 137 // the Thread's Stop method instead.
138 // 138 //
139 MessageLoop* message_loop() const { return message_loop_; } 139 MessageLoop* message_loop() const { return message_loop_; }
140 140
141 // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's 141 // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's
142 // PostTask methods to execute code on the thread. This only returns 142 // PostTask methods to execute code on the thread. This only returns
143 // non-NULL after a successful call to Start. After Stop has been called, 143 // non-NULL after a successful call to Start. After Stop has been called,
144 // this will return NULL. Callers can hold on to this even after the thread 144 // this will return NULL. Callers can hold on to this even after the thread
145 // is gone. 145 // is gone.
146 //
147 // Note: This method is deprecated. Callers should call task_runner() instead
148 // and use the TaskRunner interfaces for safely interfacing with the Thread.
146 scoped_refptr<MessageLoopProxy> message_loop_proxy() const { 149 scoped_refptr<MessageLoopProxy> message_loop_proxy() const {
147 return message_loop_ ? message_loop_->message_loop_proxy() : NULL; 150 return message_loop_ ? message_loop_->message_loop_proxy() : NULL;
148 } 151 }
149 152
153 // Returns a TaskRunner for this thread. Use the TaskRunner's PostTask
154 // 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?
155 // a successfull call to Start. After Stop has been called, this will
156 // return NULL. Callers can hold on to this even after the thread is gone;
157 // in this situation, attempts to PostTask() will fail.
158 scoped_refptr<SingleThreadTaskRunner> task_runner() const {
159 return message_loop_proxy();
160 }
161
150 // Returns the name of this thread (for display in debugger too). 162 // Returns the name of this thread (for display in debugger too).
151 const std::string& thread_name() const { return name_; } 163 const std::string& thread_name() const { return name_; }
152 164
153 // The native thread handle. 165 // The native thread handle.
154 PlatformThreadHandle thread_handle() { return thread_; } 166 PlatformThreadHandle thread_handle() { return thread_; }
155 167
156 // The thread ID. 168 // The thread ID.
157 PlatformThreadId thread_id() const { return thread_id_; } 169 PlatformThreadId thread_id() const { return thread_id_; }
158 170
159 // Returns true if the thread has been started, and not yet stopped. 171 // Returns true if the thread has been started, and not yet stopped.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 std::string name_; 236 std::string name_;
225 237
226 friend void ThreadQuitHelper(); 238 friend void ThreadQuitHelper();
227 239
228 DISALLOW_COPY_AND_ASSIGN(Thread); 240 DISALLOW_COPY_AND_ASSIGN(Thread);
229 }; 241 };
230 242
231 } // namespace base 243 } // namespace base
232 244
233 #endif // BASE_THREADING_THREAD_H_ 245 #endif // BASE_THREADING_THREAD_H_
OLDNEW
« 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