Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: base/threading/platform_thread.h

Issue 11729002: Set Realtime Audio Thread priority on Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: refactor code Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/time.h" 14 #include "base/time.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 #include <unistd.h> 21 #include <unistd.h>
22 #endif 22 #endif
23 23
24 #if defined(OS_ANDROID)
bulach 2013/01/09 12:57:58 nit: keep with the platform specific includes abov
Wei James(wistoch) 2013/01/10 08:30:05 Android also needs the header files for OS_POSIX.
25 #include "jni.h"
26 #endif
27
24 namespace base { 28 namespace base {
25 29
26 // PlatformThreadHandle should not be assumed to be a numeric type, since the 30 // PlatformThreadHandle should not be assumed to be a numeric type, since the
27 // standard intends to allow pthread_t to be a structure. This means you 31 // standard intends to allow pthread_t to be a structure. This means you
28 // should not initialize it to a value, like 0. If it's a member variable, the 32 // should not initialize it to a value, like 0. If it's a member variable, the
29 // constructor can safely "value initialize" using () in the initializer list. 33 // constructor can safely "value initialize" using () in the initializer list.
30 #if defined(OS_WIN) 34 #if defined(OS_WIN)
31 typedef DWORD PlatformThreadId; 35 typedef DWORD PlatformThreadId;
32 typedef void* PlatformThreadHandle; // HANDLE 36 typedef void* PlatformThreadHandle; // HANDLE
33 const PlatformThreadHandle kNullThreadHandle = NULL; 37 const PlatformThreadHandle kNullThreadHandle = NULL;
34 #elif defined(OS_POSIX) 38 #elif defined(OS_POSIX)
35 typedef pthread_t PlatformThreadHandle; 39 typedef pthread_t PlatformThreadHandle;
36 const PlatformThreadHandle kNullThreadHandle = 0; 40 const PlatformThreadHandle kNullThreadHandle = 0;
37 typedef pid_t PlatformThreadId; 41 typedef pid_t PlatformThreadId;
38 #endif 42 #endif
39 43
40 const PlatformThreadId kInvalidThreadId = 0; 44 const PlatformThreadId kInvalidThreadId = 0;
41 45
42 // Valid values for SetThreadPriority() 46 // Valid values for SetThreadPriority()
43 enum ThreadPriority{ 47 enum ThreadPriority{
44 kThreadPriority_Normal, 48 kThreadPriority_Normal,
45 // Suitable for low-latency, glitch-resistant audio. 49 // Suitable for low-latency, glitch-resistant audio.
46 kThreadPriority_RealtimeAudio 50 kThreadPriority_RealtimeAudio
47 }; 51 };
bulach 2013/01/09 12:57:58 nit: add a \n
Wei James(wistoch) 2013/01/10 08:30:05 fixed. thanks
52 #if defined(OS_ANDROID)
53 bool RegisterThreadUtils(JNIEnv* env);
54 #endif
48 55
49 // A namespace for low-level thread functions. 56 // A namespace for low-level thread functions.
50 class BASE_EXPORT PlatformThread { 57 class BASE_EXPORT PlatformThread {
51 public: 58 public:
52 // Implement this interface to run code on a background thread. Your 59 // Implement this interface to run code on a background thread. Your
53 // ThreadMain method will be called on the newly created thread. 60 // ThreadMain method will be called on the newly created thread.
54 class BASE_EXPORT Delegate { 61 class BASE_EXPORT Delegate {
55 public: 62 public:
56 virtual void ThreadMain() = 0; 63 virtual void ThreadMain() = 0;
57 64
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 static void SetThreadPriority(PlatformThreadHandle handle, 118 static void SetThreadPriority(PlatformThreadHandle handle,
112 ThreadPriority priority); 119 ThreadPriority priority);
113 120
114 private: 121 private:
115 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); 122 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread);
116 }; 123 };
117 124
118 } // namespace base 125 } // namespace base
119 126
120 #endif // BASE_THREADING_PLATFORM_THREAD_H_ 127 #endif // BASE_THREADING_PLATFORM_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698