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

Side by Side Diff: webrtc/base/platform_thread.cc

Issue 1476543002: Move thread_ conditional back under defines. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // Alertable sleep to permit RaiseFlag to run and update |stop_|. 195 // Alertable sleep to permit RaiseFlag to run and update |stop_|.
196 SleepEx(0, true); 196 SleepEx(0, true);
197 } while (!stop_); 197 } while (!stop_);
198 #else 198 #else
199 } while (!stop_event_.Wait(0)); 199 } while (!stop_event_.Wait(0));
200 #endif // defined(WEBRTC_WIN) 200 #endif // defined(WEBRTC_WIN)
201 } 201 }
202 202
203 bool PlatformThread::SetPriority(ThreadPriority priority) { 203 bool PlatformThread::SetPriority(ThreadPriority priority) {
204 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 204 RTC_DCHECK(thread_checker_.CalledOnValidThread());
205 if (!thread_)
206 return false;
207 #if defined(WEBRTC_WIN) 205 #if defined(WEBRTC_WIN)
208 return SetThreadPriority(thread_, priority); 206 return thread_ && SetThreadPriority(thread_, priority);
209 #elif defined(__native_client__) 207 #elif defined(__native_client__)
210 // Setting thread priorities is not supported in NaCl. 208 // Setting thread priorities is not supported in NaCl.
211 return true; 209 return true;
212 #elif defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX) 210 #elif defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
213 // TODO(tommi): Switch to the same mechanism as Chromium uses for changing 211 // TODO(tommi): Switch to the same mechanism as Chromium uses for changing
214 // thread priorities. 212 // thread priorities.
215 return true; 213 return true;
216 #else 214 #else
215 if (!thread_)
216 return false;
217 #ifdef WEBRTC_THREAD_RR 217 #ifdef WEBRTC_THREAD_RR
218 const int policy = SCHED_RR; 218 const int policy = SCHED_RR;
219 #else 219 #else
220 const int policy = SCHED_FIFO; 220 const int policy = SCHED_FIFO;
221 #endif 221 #endif
222 const int min_prio = sched_get_priority_min(policy); 222 const int min_prio = sched_get_priority_min(policy);
223 const int max_prio = sched_get_priority_max(policy); 223 const int max_prio = sched_get_priority_max(policy);
224 if (min_prio == -1 || max_prio == -1) { 224 if (min_prio == -1 || max_prio == -1) {
225 return false; 225 return false;
226 } 226 }
(...skipping 22 matching lines...) Expand all
249 break; 249 break;
250 case kRealtimePriority: 250 case kRealtimePriority:
251 param.sched_priority = top_prio; 251 param.sched_priority = top_prio;
252 break; 252 break;
253 } 253 }
254 return pthread_setschedparam(thread_, policy, &param) == 0; 254 return pthread_setschedparam(thread_, policy, &param) == 0;
255 #endif // defined(WEBRTC_WIN) 255 #endif // defined(WEBRTC_WIN)
256 } 256 }
257 257
258 } // namespace webrtc 258 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698