summaryrefslogtreecommitdiff
path: root/platform/default
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-01-31 17:01:12 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-02-06 23:54:19 +0200
commit4be2fa4f9af29cfad869412d2d794964554d4eba (patch)
tree94d2b3f93457242930f43a2171714c5ce06634df /platform/default
parent5789faf11ae2a740927bce599a209883a78b113e (diff)
downloadqtlocation-mapboxgl-4be2fa4f9af29cfad869412d2d794964554d4eba.tar.gz
[core] Add platform::setCurrentThreadPriority(double)
Diffstat (limited to 'platform/default')
-rw-r--r--platform/default/src/mbgl/util/thread.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/platform/default/src/mbgl/util/thread.cpp b/platform/default/src/mbgl/util/thread.cpp
index 58a7c12bc8..1ee5b12119 100644
--- a/platform/default/src/mbgl/util/thread.cpp
+++ b/platform/default/src/mbgl/util/thread.cpp
@@ -6,6 +6,7 @@
#include <pthread.h>
#include <sched.h>
+#include <sys/resource.h>
namespace mbgl {
namespace platform {
@@ -40,11 +41,23 @@ void makeThreadLowPriority() {
#endif
}
-void attachThread() {
-}
+void setCurrentThreadPriority(double priority) {
+ if (setpriority(PRIO_PROCESS, 0, int(priority)) < 0) {
+ Log::Warning(Event::General, "Couldn't set thread priority");
+ }
-void detachThread() {
+#ifdef SCHED_OTHER
+ struct sched_param param;
+ param.sched_priority = 0;
+ if (sched_setscheduler(0, SCHED_OTHER, &param) != 0) {
+ Log::Warning(Event::General, "Couldn't set thread scheduling policy");
+ }
+#endif
}
+void attachThread() {}
+
+void detachThread() {}
+
} // namespace platform
} // namespace mbgl