| 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 // WARNING: You should *NOT* be using this class directly. PlatformThread is | 5 // WARNING: You should *NOT* be using this class directly. PlatformThread is |
| 6 // the low-level platform-specific abstraction to the OS's threading interface. | 6 // the low-level platform-specific abstraction to the OS's threading interface. |
| 7 // You should instead be using a message-loop driven Thread, see thread.h. | 7 // You should instead be using a message-loop driven Thread, see thread.h. |
| 8 | 8 |
| 9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_ | 9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_ |
| 10 #define BASE_THREADING_PLATFORM_THREAD_H_ | 10 #define BASE_THREADING_PLATFORM_THREAD_H_ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 : handle_(handle), | 82 : handle_(handle), |
| 83 id_(0) { | 83 id_(0) { |
| 84 } | 84 } |
| 85 | 85 |
| 86 PlatformThreadHandle(Handle handle, | 86 PlatformThreadHandle(Handle handle, |
| 87 PlatformThreadId id) | 87 PlatformThreadId id) |
| 88 : handle_(handle), | 88 : handle_(handle), |
| 89 id_(id) { | 89 id_(id) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 PlatformThreadId id() const { |
| 93 return id_; |
| 94 } |
| 95 |
| 92 bool is_equal(const PlatformThreadHandle& other) const { | 96 bool is_equal(const PlatformThreadHandle& other) const { |
| 93 return handle_ == other.handle_; | 97 return handle_ == other.handle_; |
| 94 } | 98 } |
| 95 | 99 |
| 96 bool is_null() const { | 100 bool is_null() const { |
| 97 return !handle_; | 101 return !handle_; |
| 98 } | 102 } |
| 99 | 103 |
| 100 Handle platform_handle() const { | 104 Handle platform_handle() const { |
| 101 return handle_; | 105 return handle_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // the current thread from another. | 153 // the current thread from another. |
| 150 static PlatformThreadHandle CurrentHandle(); | 154 static PlatformThreadHandle CurrentHandle(); |
| 151 | 155 |
| 152 // Yield the current thread so another thread can be scheduled. | 156 // Yield the current thread so another thread can be scheduled. |
| 153 static void YieldCurrentThread(); | 157 static void YieldCurrentThread(); |
| 154 | 158 |
| 155 // Sleeps for the specified duration. | 159 // Sleeps for the specified duration. |
| 156 static void Sleep(base::TimeDelta duration); | 160 static void Sleep(base::TimeDelta duration); |
| 157 | 161 |
| 158 // Sets the thread name visible to debuggers/tools. This has no effect | 162 // Sets the thread name visible to debuggers/tools. This has no effect |
| 159 // otherwise. This name pointer is not copied internally. Thus, it must stay | 163 // otherwise. |
| 160 // valid until the thread ends. | 164 static void SetName(const std::string& name); |
| 161 static void SetName(const char* name); | |
| 162 | 165 |
| 163 // Gets the thread name, if previously set by SetName. | 166 // Gets the thread name, if previously set by SetName. |
| 164 static const char* GetName(); | 167 static const char* GetName(); |
| 165 | 168 |
| 166 // Creates a new thread. The |stack_size| parameter can be 0 to indicate | 169 // Creates a new thread. The |stack_size| parameter can be 0 to indicate |
| 167 // that the default stack size should be used. Upon success, | 170 // that the default stack size should be used. Upon success, |
| 168 // |*thread_handle| will be assigned a handle to the newly created thread, | 171 // |*thread_handle| will be assigned a handle to the newly created thread, |
| 169 // and |delegate|'s ThreadMain method will be executed on the newly created | 172 // and |delegate|'s ThreadMain method will be executed on the newly created |
| 170 // thread. | 173 // thread. |
| 171 // NOTE: When you are done with the thread handle, you must call Join to | 174 // NOTE: When you are done with the thread handle, you must call Join to |
| (...skipping 24 matching lines...) Expand all Loading... |
| 196 | 199 |
| 197 static ThreadPriority GetThreadPriority(PlatformThreadHandle handle); | 200 static ThreadPriority GetThreadPriority(PlatformThreadHandle handle); |
| 198 | 201 |
| 199 private: | 202 private: |
| 200 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 203 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
| 201 }; | 204 }; |
| 202 | 205 |
| 203 } // namespace base | 206 } // namespace base |
| 204 | 207 |
| 205 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 208 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
| OLD | NEW |