summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorcrogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 21:28:02 +0000
committercrogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 21:28:02 +0000
commit2bfec66b07c9a615e0e809a13e26dd7325172ea1 (patch)
tree978af4d7b17799de6ea9f807552a24adc69519a4 /base
parentc6ee7a0e6142b6b2c2958154ad60b4aba95f266f (diff)
downloadchromium_src-2bfec66b07c9a615e0e809a13e26dd7325172ea1.zip
chromium_src-2bfec66b07c9a615e0e809a13e26dd7325172ea1.tar.gz
chromium_src-2bfec66b07c9a615e0e809a13e26dd7325172ea1.tar.bz2
Don't DCHECK thread_policy_set() calls because they can fail during runtime
BUG=95274 TEST=none Review URL: http://codereview.chromium.org/7789007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/threading/platform_thread_mac.mm26
1 files changed, 21 insertions, 5 deletions
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index 9894a1d..cff7a1f 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -68,13 +68,16 @@ namespace {
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 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) {
// 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,8 +99,10 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) {
THREAD_EXTENDED_POLICY,
(thread_policy_t)&policy,
THREAD_EXTENDED_POLICY_COUNT);
-
- DCHECK_EQ(KERN_SUCCESS, result);
+ if (result != KERN_SUCCESS) {
+ VLOG(1) << "thread_policy_set() failure: " << result;
+ return;
+ }
// Set to relatively high priority.
thread_precedence_policy_data_t precedence;
@@ -101,7 +111,10 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) {
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 @@ void SetPriorityRealtimeAudio(mach_port_t mach_thread_id) {
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