| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // running (e.g. before Start or after Stop have been called). Callers can | 165 // running (e.g. before Start or after Stop have been called). Callers can |
| 166 // hold on to this even after the thread is gone; in this situation, attempts | 166 // hold on to this even after the thread is gone; in this situation, attempts |
| 167 // to PostTask() will fail. | 167 // to PostTask() will fail. |
| 168 scoped_refptr<SingleThreadTaskRunner> task_runner() const { | 168 scoped_refptr<SingleThreadTaskRunner> task_runner() const { |
| 169 return message_loop_ ? message_loop_->task_runner() : nullptr; | 169 return message_loop_ ? message_loop_->task_runner() : nullptr; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Returns the name of this thread (for display in debugger too). | 172 // Returns the name of this thread (for display in debugger too). |
| 173 const std::string& thread_name() const { return name_; } | 173 const std::string& thread_name() const { return name_; } |
| 174 | 174 |
| 175 // The native thread handle. | |
| 176 PlatformThreadHandle thread_handle() { return thread_; } | |
| 177 | |
| 178 // Returns the thread ID. Should not be called before the first Start*() | 175 // Returns the thread ID. Should not be called before the first Start*() |
| 179 // call. Keeps on returning the same ID even after a Stop() call. The next | 176 // call. Keeps on returning the same ID even after a Stop() call. The next |
| 180 // Start*() call renews the ID. | 177 // Start*() call renews the ID. |
| 181 // | 178 // |
| 182 // WARNING: This function will block if the thread hasn't started yet. | 179 // WARNING: This function will block if the thread hasn't started yet. |
| 183 // | 180 // |
| 184 PlatformThreadId GetThreadId() const; | 181 PlatformThreadId GetThreadId() const; |
| 185 | 182 |
| 186 // Returns true if the thread has been started, and not yet stopped. | 183 // Returns true if the thread has been started, and not yet stopped. |
| 187 bool IsRunning() const; | 184 bool IsRunning() const; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 mutable WaitableEvent start_event_; | 250 mutable WaitableEvent start_event_; |
| 254 | 251 |
| 255 friend void ThreadQuitHelper(); | 252 friend void ThreadQuitHelper(); |
| 256 | 253 |
| 257 DISALLOW_COPY_AND_ASSIGN(Thread); | 254 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 258 }; | 255 }; |
| 259 | 256 |
| 260 } // namespace base | 257 } // namespace base |
| 261 | 258 |
| 262 #endif // BASE_THREADING_THREAD_H_ | 259 #endif // BASE_THREADING_THREAD_H_ |
| OLD | NEW |