Files
MapLibreParticleLab/platform/darwin/core/nsthread.mm
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

51 lines
1.3 KiB
Plaintext

#import <Foundation/Foundation.h>
#include <mln/platform/thread.hpp>
#include <mln/util/logging.hpp>
#include <mln/util/platform.hpp>
#include <pthread.h>
namespace mln {
namespace platform {
std::string getCurrentThreadName() {
char name[32] = "unknown";
pthread_getname_np(pthread_self(), name, sizeof(name));
return name;
}
void setCurrentThreadName(const std::string& name) {
std::string qualifiedName = "org.maplibre.mbgl." + name;
pthread_setname_np(qualifiedName.c_str());
}
void makeThreadLowPriority() {
[NSThread currentThread].qualityOfService = NSQualityOfServiceUtility;
}
void setCurrentThreadPriority(double priority) {
if (priority > 1.0 || priority < 0.0) {
Log::Warning(Event::General, "Invalid thread priority was provided");
return;
}
if (priority < 0.25) {
[NSThread currentThread].qualityOfService = NSQualityOfServiceBackground;
} else if (priority < 0.5) {
[NSThread currentThread].qualityOfService = NSQualityOfServiceUtility;
} else if (priority < 0.75) {
[NSThread currentThread].qualityOfService = NSQualityOfServiceUserInitiated;
} else {
[NSThread currentThread].qualityOfService = NSQualityOfServiceUserInteractive;
}
}
void attachThread() {}
void detachThread() {}
} // namespace platform
} // namespace mln