Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 // Used to operate on threads. | 67 // Used to operate on threads. |
| 68 class PlatformThreadHandle { | 68 class PlatformThreadHandle { |
| 69 public: | 69 public: |
| 70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 71 typedef void* Handle; | 71 typedef void* Handle; |
| 72 #elif defined(OS_POSIX) | 72 #elif defined(OS_POSIX) |
| 73 typedef pthread_t Handle; | 73 typedef pthread_t Handle; |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 PlatformThreadHandle() | 76 PlatformThreadHandle() : handle_(0) {} |
| 77 : handle_(0), | |
| 78 id_(0) { | |
| 79 } | |
| 80 | 77 |
| 81 explicit PlatformThreadHandle(Handle handle) | 78 explicit PlatformThreadHandle(Handle handle) : handle_(handle) {} |
| 82 : handle_(handle), | |
| 83 id_(0) { | |
| 84 } | |
| 85 | |
| 86 PlatformThreadHandle(Handle handle, | |
| 87 PlatformThreadId id) | |
| 88 : handle_(handle), | |
| 89 id_(id) { | |
| 90 } | |
| 91 | |
| 92 // TODO(toyoshim): Remove id() and use PlatformThread::CurrentId() instead. | |
| 93 PlatformThreadId id() const { | |
| 94 return id_; | |
| 95 } | |
| 96 | 79 |
| 97 bool is_equal(const PlatformThreadHandle& other) const { | 80 bool is_equal(const PlatformThreadHandle& other) const { |
| 98 return handle_ == other.handle_; | 81 return handle_ == other.handle_; |
| 99 } | 82 } |
| 100 | 83 |
| 101 bool is_null() const { | 84 bool is_null() const { |
| 102 return !handle_; | 85 return !handle_; |
| 103 } | 86 } |
| 104 | 87 |
| 105 Handle platform_handle() const { | |
| 106 return handle_; | |
| 107 } | |
| 108 | |
| 109 private: | 88 private: |
| 89 friend class MessagePumpForUI; | |
| 90 friend class PlatformThread; | |
| 91 friend class ThreadIdNameManager; | |
|
gab
2015/06/30 13:57:34
I don't like using friend and I don't think I mind
Takashi Toyoshima
2015/07/02 06:34:28
OK, let me upload another patch set.
| |
| 110 Handle handle_; | 92 Handle handle_; |
| 111 PlatformThreadId id_; | |
| 112 }; | 93 }; |
| 113 | 94 |
| 114 const PlatformThreadId kInvalidThreadId(0); | 95 const PlatformThreadId kInvalidThreadId(0); |
| 115 | 96 |
| 116 // Valid values for priority of Thread::Options and SimpleThread::Options, and | 97 // Valid values for priority of Thread::Options and SimpleThread::Options, and |
| 117 // SetCurrentThreadPriority(), listed in increasing order of importance. | 98 // SetCurrentThreadPriority(), listed in increasing order of importance. |
| 118 enum class ThreadPriority { | 99 enum class ThreadPriority { |
| 119 // Suitable for threads that shouldn't disrupt high priority work. | 100 // Suitable for threads that shouldn't disrupt high priority work. |
| 120 BACKGROUND, | 101 BACKGROUND, |
| 121 // Default priority level. | 102 // Default priority level. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 | 183 |
| 203 static ThreadPriority GetCurrentThreadPriority(); | 184 static ThreadPriority GetCurrentThreadPriority(); |
| 204 | 185 |
| 205 private: | 186 private: |
| 206 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 187 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
| 207 }; | 188 }; |
| 208 | 189 |
| 209 } // namespace base | 190 } // namespace base |
| 210 | 191 |
| 211 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 192 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
| OLD | NEW |