[core] Add hooks for setting experimental thread priorities for mbgl threads

This commit is contained in:
Alexander Shalamov
2020-01-31 17:06:37 +02:00
parent 4be2fa4f9a
commit bb85ec442d
11 changed files with 88 additions and 31 deletions

View File

@@ -1,8 +1,9 @@
#include <mbgl/util/thread_pool.hpp>
#include <mbgl/platform/settings.hpp>
#include <mbgl/platform/thread.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/platform/thread.hpp>
namespace mbgl {
@@ -17,7 +18,13 @@ void ThreadedSchedulerBase::terminate() {
}
std::thread ThreadedSchedulerBase::makeSchedulerThread(size_t index) {
return std::thread([this, index]() {
return std::thread([this, index] {
auto& settings = platform::Settings::getInstance();
auto value = settings.get(platform::EXPERIMENTAL_THREAD_PRIORITY_WORKER);
if (auto* priority = value.getDouble()) {
platform::setCurrentThreadPriority(*priority);
}
platform::setCurrentThreadName(std::string{"Worker "} + util::toString(index + 1));
platform::attachThread();