| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 kThreadPriority_RealtimeAudio | 47 kThreadPriority_RealtimeAudio |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // A namespace for low-level thread functions. | 50 // A namespace for low-level thread functions. |
| 51 class BASE_EXPORT PlatformThread { | 51 class BASE_EXPORT PlatformThread { |
| 52 public: | 52 public: |
| 53 // Implement this interface to run code on a background thread. Your | 53 // Implement this interface to run code on a background thread. Your |
| 54 // ThreadMain method will be called on the newly created thread. | 54 // ThreadMain method will be called on the newly created thread. |
| 55 class BASE_EXPORT Delegate { | 55 class BASE_EXPORT Delegate { |
| 56 public: | 56 public: |
| 57 virtual void ThreadMain() = 0; |
| 58 |
| 59 protected: |
| 57 virtual ~Delegate() {} | 60 virtual ~Delegate() {} |
| 58 virtual void ThreadMain() = 0; | |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 // Gets the current thread id, which may be useful for logging purposes. | 63 // Gets the current thread id, which may be useful for logging purposes. |
| 62 static PlatformThreadId CurrentId(); | 64 static PlatformThreadId CurrentId(); |
| 63 | 65 |
| 64 // Yield the current thread so another thread can be scheduled. | 66 // Yield the current thread so another thread can be scheduled. |
| 65 static void YieldCurrentThread(); | 67 static void YieldCurrentThread(); |
| 66 | 68 |
| 67 // Sleeps for the specified duration. | 69 // Sleeps for the specified duration. |
| 68 static void Sleep(base::TimeDelta duration); | 70 static void Sleep(base::TimeDelta duration); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 static void SetThreadPriority(PlatformThreadHandle handle, | 112 static void SetThreadPriority(PlatformThreadHandle handle, |
| 111 ThreadPriority priority); | 113 ThreadPriority priority); |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 116 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 } // namespace base | 119 } // namespace base |
| 118 | 120 |
| 119 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 121 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
| OLD | NEW |