Files
MapLibreParticleLab/platform/default/thread.cpp
Konstantin Käfer 24285926c2 [core] Include Linux-specific scheduling header
before, builds for Linux didn't include thread priority control
2015-11-05 10:32:45 +01:00

29 lines
599 B
C++

#include <mbgl/platform/platform.hpp>
#include <mbgl/platform/log.hpp>
#include <pthread.h>
#ifdef __linux__
#include <linux/sched.h>
#endif
#include <sched.h>
namespace mbgl {
namespace platform {
void makeThreadLowPriority() {
#ifdef SCHED_IDLE
struct sched_param param;
param.sched_priority = 0;
int status = sched_setscheduler(0, SCHED_IDLE, &param);
if (status != 0) {
Log::Warning(Event::General, "Couldn't set thread scheduling policy");
}
#else
#pragma message("Building without thread priority control")
#endif
}
} // namespace platform
} // namespace mbgl