[core] Add hooks for setting experimental thread priorities for mbgl threads
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
"src/mbgl/map/transform_state.cpp",
|
||||
"src/mbgl/math/log2.cpp",
|
||||
"src/mbgl/platform/gl_functions.cpp",
|
||||
"src/mbgl/platform/settings.cpp",
|
||||
"src/mbgl/programs/background_program.cpp",
|
||||
"src/mbgl/programs/circle_program.cpp",
|
||||
"src/mbgl/programs/clipping_mask_program.cpp",
|
||||
@@ -316,6 +317,7 @@
|
||||
"src/mbgl/util/rapidjson.cpp",
|
||||
"src/mbgl/util/stopwatch.cpp",
|
||||
"src/mbgl/util/string.cpp",
|
||||
"src/mbgl/util/thread.cpp",
|
||||
"src/mbgl/util/thread_pool.cpp",
|
||||
"src/mbgl/util/tile_cover.cpp",
|
||||
"src/mbgl/util/tile_cover_impl.cpp",
|
||||
@@ -369,6 +371,7 @@
|
||||
"mbgl/math/minmax.hpp": "include/mbgl/math/minmax.hpp",
|
||||
"mbgl/math/wrap.hpp": "include/mbgl/math/wrap.hpp",
|
||||
"mbgl/platform/gl_functions.hpp": "include/mbgl/platform/gl_functions.hpp",
|
||||
"mbgl/platform/settings.hpp": "include/mbgl/platform/settings.hpp",
|
||||
"mbgl/platform/thread.hpp": "include/mbgl/platform/thread.hpp",
|
||||
"mbgl/renderer/query.hpp": "include/mbgl/renderer/query.hpp",
|
||||
"mbgl/renderer/renderer.hpp": "include/mbgl/renderer/renderer.hpp",
|
||||
|
||||
19
src/mbgl/util/thread.cpp
Normal file
19
src/mbgl/util/thread.cpp
Normal file
@@ -0,0 +1,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
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user