summaryrefslogtreecommitdiff
path: root/xpcom/glue/nsThreadUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xpcom/glue/nsThreadUtils.cpp')
-rw-r--r--xpcom/glue/nsThreadUtils.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp
index 8743c0d5fb..b6a37a7b83 100644
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -19,6 +19,8 @@
#ifdef XP_WIN
#include <windows.h>
+#elif defined(XP_MACOSX)
+#include <sys/resource.h>
#endif
using namespace mozilla;
@@ -437,6 +439,12 @@ nsAutoLowPriorityIO::nsAutoLowPriorityIO()
#if defined(XP_WIN)
lowIOPrioritySet = SetThreadPriority(GetCurrentThread(),
THREAD_MODE_BACKGROUND_BEGIN);
+#elif defined(XP_MACOSX)
+ oldPriority = getiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD);
+ lowIOPrioritySet = oldPriority != -1 &&
+ setiopolicy_np(IOPOL_TYPE_DISK,
+ IOPOL_SCOPE_THREAD,
+ IOPOL_THROTTLE) != -1;
#else
lowIOPrioritySet = false;
#endif
@@ -449,5 +457,9 @@ nsAutoLowPriorityIO::~nsAutoLowPriorityIO()
// On Windows the old thread priority is automatically restored
SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_END);
}
+#elif defined(XP_MACOSX)
+ if (MOZ_LIKELY(lowIOPrioritySet)) {
+ setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD, oldPriority);
+ }
#endif
}