summaryrefslogtreecommitdiff
path: root/src/mbgl/util/thread.cpp
blob: 016d23a9286f38afc9acabbc8d23401dca4d2cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <functional>
#include <mbgl/platform/settings.hpp>
#include <mbgl/util/platform.hpp>

namespace mbgl {
namespace util {
std::function<void()> makeThreadPrioritySetter(std::string threadType_) {
    return [threadType = std::move(threadType_)] {
        auto& settings = platform::Settings::getInstance();
        auto value = settings.get(threadType);
        if (auto* priority = value.getDouble()) {
            platform::setCurrentThreadPriority(*priority);
        } else {
            platform::makeThreadLowPriority();
        }
    };
}
} // namespace util
} // namespace mbgl