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

Unified Diff: base/threading/platform_thread_mac.mm

Issue 7789007: Don't DCHECK thread_policy_set() calls because they can fail during runtime (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_mac.mm
===================================================================
--- base/threading/platform_thread_mac.mm (revision 99454)
+++ base/threading/platform_thread_mac.mm (working copy)
@@ -68,13 +68,16 @@
void SetPriorityNormal(mach_port_t mach_thread_id) {
// Make thread standard policy.
+ // Please note that this call could fail in rare cases depending
+ // on runtime conditions.
thread_standard_policy policy;
kern_return_t result = thread_policy_set(mach_thread_id,
THREAD_STANDARD_POLICY,
(thread_policy_t)&policy,
THREAD_STANDARD_POLICY_COUNT);
- DCHECK_EQ(KERN_SUCCESS, result);
+ if (result != KERN_SUCCESS)
+ VLOG(1) << "thread_policy_set() failure: " << result;
}
// Enables time-contraint policy and priority suitable for low-latency,
@@ -84,6 +87,11 @@
// Increase thread priority to real-time.
+ // Please note that the thread_policy_set() calls may fail in
+ // rare cases if the kernel decides the system is under heavy load
+ // and is unable to handle boosting the thread priority.
+ // In these cases we just return early and go on with life.
+
// Make thread fixed priority.
thread_extended_policy_data_t policy;
policy.timeshare = 0; // Set to 1 for a non-fixed thread.
@@ -91,9 +99,11 @@
THREAD_EXTENDED_POLICY,
(thread_policy_t)&policy,
THREAD_EXTENDED_POLICY_COUNT);
+ if (result != KERN_SUCCESS) {
+ VLOG(1) << "thread_policy_set() failure: " << result;
+ return;
+ }
- DCHECK_EQ(KERN_SUCCESS, result);
-
// Set to relatively high priority.
thread_precedence_policy_data_t precedence;
precedence.importance = 63;
@@ -101,7 +111,10 @@
THREAD_PRECEDENCE_POLICY,
(thread_policy_t)&precedence,
THREAD_PRECEDENCE_POLICY_COUNT);
- DCHECK_EQ(KERN_SUCCESS, result);
+ if (result != KERN_SUCCESS) {
+ VLOG(1) << "thread_policy_set() failure: " << result;
+ return;
+ }
// Most important, set real-time constraints.
@@ -142,7 +155,10 @@
THREAD_TIME_CONSTRAINT_POLICY,
(thread_policy_t)&time_constraints,
THREAD_TIME_CONSTRAINT_POLICY_COUNT);
- DCHECK_EQ(KERN_SUCCESS, result);
+ if (result != KERN_SUCCESS)
+ VLOG(1) << "thread_policy_set() failure: " << result;
+
+ return;
}
} // anonymous namespace
« 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