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

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

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back JNI for Audio. Created 7 years, 8 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_
(...skipping 25 matching lines...) Expand all
36 const PlatformThreadHandle kNullThreadHandle = 0; 36 const PlatformThreadHandle kNullThreadHandle = 0;
37 typedef pid_t PlatformThreadId; 37 typedef pid_t PlatformThreadId;
38 #endif 38 #endif
39 39
40 const PlatformThreadId kInvalidThreadId = 0; 40 const PlatformThreadId kInvalidThreadId = 0;
41 41
42 // Valid values for SetThreadPriority() 42 // Valid values for SetThreadPriority()
43 enum ThreadPriority{ 43 enum ThreadPriority{
44 kThreadPriority_Normal, 44 kThreadPriority_Normal,
45 // Suitable for low-latency, glitch-resistant audio. 45 // Suitable for low-latency, glitch-resistant audio.
46 kThreadPriority_RealtimeAudio 46 kThreadPriority_RealtimeAudio,
47 kThreadPriority_Display,
jar (doing other things) 2013/04/24 01:04:57 Although I can guess what Normal means, vs Backgro
epenner 2013/04/30 04:37:08 Done.
48 kThreadPriority_Background
47 }; 49 };
48 50
49 // A namespace for low-level thread functions. 51 // A namespace for low-level thread functions.
50 class BASE_EXPORT PlatformThread { 52 class BASE_EXPORT PlatformThread {
51 public: 53 public:
52 // Implement this interface to run code on a background thread. Your 54 // Implement this interface to run code on a background thread. Your
53 // ThreadMain method will be called on the newly created thread. 55 // ThreadMain method will be called on the newly created thread.
54 class BASE_EXPORT Delegate { 56 class BASE_EXPORT Delegate {
55 public: 57 public:
56 virtual void ThreadMain() = 0; 58 virtual void ThreadMain() = 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // CreateNonJoinable() does the same thing as Create() except the thread 101 // CreateNonJoinable() does the same thing as Create() except the thread
100 // cannot be Join()'d. Therefore, it also does not output a 102 // cannot be Join()'d. Therefore, it also does not output a
101 // PlatformThreadHandle. 103 // PlatformThreadHandle.
102 static bool CreateNonJoinable(size_t stack_size, Delegate* delegate); 104 static bool CreateNonJoinable(size_t stack_size, Delegate* delegate);
103 105
104 // Joins with a thread created via the Create function. This function blocks 106 // Joins with a thread created via the Create function. This function blocks
105 // the caller until the designated thread exits. This will invalidate 107 // the caller until the designated thread exits. This will invalidate
106 // |thread_handle|. 108 // |thread_handle|.
107 static void Join(PlatformThreadHandle thread_handle); 109 static void Join(PlatformThreadHandle thread_handle);
108 110
109 // Sets the priority of the thread specified in |handle| to |priority|. 111 // Only one of the handle/id is required depending on the
110 // This does not work on Linux, use CreateWithPriority() instead. 112 // platform. However, for cross platform code, pass both.
111 static void SetThreadPriority(PlatformThreadHandle handle, 113 static void SetThreadPriority(PlatformThreadHandle handle,
114 PlatformThreadId id,
jar (doing other things) 2013/04/24 01:04:57 Rather than having both, can you unify this in a c
epenner 2013/04/30 04:37:08 See also my previous general comment on the patch.
112 ThreadPriority priority); 115 ThreadPriority priority);
113
jar (doing other things) 2013/04/24 01:04:57 nit: preserve the white-space line before the priv
epenner 2013/04/30 04:37:08 Done.
114 private: 116 private:
115 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); 117 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread);
116 }; 118 };
117 119
118 } // namespace base 120 } // namespace base
119 121
120 #endif // BASE_THREADING_PLATFORM_THREAD_H_ 122 #endif // BASE_THREADING_PLATFORM_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/platform_thread_mac.mm » ('j') | base/threading/platform_thread_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698