OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include "base/base_api.h" | 13 #include "base/base_export.h" |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 | 16 |
17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
18 #include <windows.h> | 18 #include <windows.h> |
19 #elif defined(OS_POSIX) | 19 #elif defined(OS_POSIX) |
20 #include <pthread.h> | 20 #include <pthread.h> |
21 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
22 #include <mach/mach.h> | 22 #include <mach/mach.h> |
23 #else // OS_POSIX && !OS_MACOSX | 23 #else // OS_POSIX && !OS_MACOSX |
(...skipping 24 matching lines...) Expand all Loading... |
48 const PlatformThreadId kInvalidThreadId = 0; | 48 const PlatformThreadId kInvalidThreadId = 0; |
49 | 49 |
50 // Valid values for SetThreadPriority() | 50 // Valid values for SetThreadPriority() |
51 enum ThreadPriority{ | 51 enum ThreadPriority{ |
52 kThreadPriority_Normal, | 52 kThreadPriority_Normal, |
53 // Suitable for low-latency, glitch-resistant audio. | 53 // Suitable for low-latency, glitch-resistant audio. |
54 kThreadPriority_RealtimeAudio | 54 kThreadPriority_RealtimeAudio |
55 }; | 55 }; |
56 | 56 |
57 // A namespace for low-level thread functions. | 57 // A namespace for low-level thread functions. |
58 class BASE_API PlatformThread { | 58 class BASE_EXPORT PlatformThread { |
59 public: | 59 public: |
60 // Implement this interface to run code on a background thread. Your | 60 // Implement this interface to run code on a background thread. Your |
61 // ThreadMain method will be called on the newly created thread. | 61 // ThreadMain method will be called on the newly created thread. |
62 class BASE_API Delegate { | 62 class BASE_EXPORT Delegate { |
63 public: | 63 public: |
64 virtual ~Delegate() {} | 64 virtual ~Delegate() {} |
65 virtual void ThreadMain() = 0; | 65 virtual void ThreadMain() = 0; |
66 }; | 66 }; |
67 | 67 |
68 // Gets the current thread id, which may be useful for logging purposes. | 68 // Gets the current thread id, which may be useful for logging purposes. |
69 static PlatformThreadId CurrentId(); | 69 static PlatformThreadId CurrentId(); |
70 | 70 |
71 // Yield the current thread so another thread can be scheduled. | 71 // Yield the current thread so another thread can be scheduled. |
72 static void YieldCurrentThread(); | 72 static void YieldCurrentThread(); |
(...skipping 28 matching lines...) Expand all Loading... |
101 static void SetThreadPriority(PlatformThreadHandle handle, | 101 static void SetThreadPriority(PlatformThreadHandle handle, |
102 ThreadPriority priority); | 102 ThreadPriority priority); |
103 | 103 |
104 private: | 104 private: |
105 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 105 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace base | 108 } // namespace base |
109 | 109 |
110 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 110 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
OLD | NEW |