diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-01-31 17:06:37 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-06 23:54:19 +0200 |
commit | bb85ec442dd7b5b0966d73bc6b868d33bb03e5e9 (patch) | |
tree | e0fef3271ab6e4f21b05f4f00dd6aa4386efd499 /platform | |
parent | 4be2fa4f9af29cfad869412d2d794964554d4eba (diff) | |
download | qtlocation-mapboxgl-bb85ec442dd7b5b0966d73bc6b868d33bb03e5e9.tar.gz |
[core] Add hooks for setting experimental thread priorities for mbgl threads
Diffstat (limited to 'platform')
6 files changed, 33 insertions, 14 deletions
diff --git a/platform/android/src/asset_manager_file_source.cpp b/platform/android/src/asset_manager_file_source.cpp index 73ecec2b05..a8045a2b96 100644 --- a/platform/android/src/asset_manager_file_source.cpp +++ b/platform/android/src/asset_manager_file_source.cpp @@ -1,5 +1,6 @@ #include "asset_manager_file_source.hpp" +#include <mbgl/platform/settings.hpp> #include <mbgl/storage/file_source_request.hpp> #include <mbgl/storage/resource.hpp> #include <mbgl/storage/response.hpp> @@ -39,11 +40,13 @@ private: AAssetManager* assetManager; }; -AssetManagerFileSource::AssetManagerFileSource(jni::JNIEnv& env, const jni::Object<android::AssetManager>& assetManager_) +AssetManagerFileSource::AssetManagerFileSource(jni::JNIEnv& env, + const jni::Object<android::AssetManager>& assetManager_) : assetManager(jni::NewGlobal(env, assetManager_)), - impl(std::make_unique<util::Thread<Impl>>("AssetManagerFileSource", - AAssetManager_fromJava(&env, jni::Unwrap(assetManager.get())))) { -} + impl(std::make_unique<util::Thread<Impl>>( + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_FILE), + "AssetManagerFileSource", + AAssetManager_fromJava(&env, jni::Unwrap(assetManager.get())))) {} AssetManagerFileSource::~AssetManagerFileSource() = default; diff --git a/platform/default/src/mbgl/storage/asset_file_source.cpp b/platform/default/src/mbgl/storage/asset_file_source.cpp index 7abd609b19..a9ede06508 100644 --- a/platform/default/src/mbgl/storage/asset_file_source.cpp +++ b/platform/default/src/mbgl/storage/asset_file_source.cpp @@ -1,3 +1,4 @@ +#include <mbgl/platform/settings.hpp> #include <mbgl/storage/asset_file_source.hpp> #include <mbgl/storage/file_source_request.hpp> #include <mbgl/storage/local_file_request.hpp> @@ -42,8 +43,8 @@ private: }; AssetFileSource::AssetFileSource(const std::string& root) - : impl(std::make_unique<util::Thread<Impl>>("AssetFileSource", root)) { -} + : impl(std::make_unique<util::Thread<Impl>>( + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_FILE), "AssetFileSource", root)) {} AssetFileSource::~AssetFileSource() = default; diff --git a/platform/default/src/mbgl/storage/database_file_source.cpp b/platform/default/src/mbgl/storage/database_file_source.cpp index b46693849a..f0b4849cb0 100644 --- a/platform/default/src/mbgl/storage/database_file_source.cpp +++ b/platform/default/src/mbgl/storage/database_file_source.cpp @@ -1,3 +1,4 @@ +#include <mbgl/platform/settings.hpp> #include <mbgl/storage/database_file_source.hpp> #include <mbgl/storage/file_source_manager.hpp> #include <mbgl/storage/file_source_request.hpp> @@ -7,6 +8,7 @@ #include <mbgl/storage/response.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/util/logging.hpp> +#include <mbgl/util/platform.hpp> #include <mbgl/util/thread.hpp> namespace mbgl { @@ -149,7 +151,10 @@ class DatabaseFileSource::Impl { public: Impl(std::shared_ptr<FileSource> onlineFileSource, const std::string& cachePath) : thread(std::make_unique<util::Thread<DatabaseFileSourceThread>>( - "DatabaseFileSource", std::move(onlineFileSource), cachePath)) {} + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_DATABASE), + "DatabaseFileSource", + std::move(onlineFileSource), + cachePath)) {} ActorRef<DatabaseFileSourceThread> actor() const { return thread->actor(); } diff --git a/platform/default/src/mbgl/storage/local_file_source.cpp b/platform/default/src/mbgl/storage/local_file_source.cpp index 54f12baf79..5009146c8e 100644 --- a/platform/default/src/mbgl/storage/local_file_source.cpp +++ b/platform/default/src/mbgl/storage/local_file_source.cpp @@ -1,3 +1,4 @@ +#include <mbgl/platform/settings.hpp> #include <mbgl/storage/file_source_request.hpp> #include <mbgl/storage/local_file_request.hpp> #include <mbgl/storage/local_file_source.hpp> @@ -36,8 +37,8 @@ public: }; LocalFileSource::LocalFileSource() - : impl(std::make_unique<util::Thread<Impl>>("LocalFileSource")) { -} + : impl(std::make_unique<util::Thread<Impl>>( + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_FILE), "LocalFileSource")) {} LocalFileSource::~LocalFileSource() = default; diff --git a/platform/default/src/mbgl/storage/main_resource_loader.cpp b/platform/default/src/mbgl/storage/main_resource_loader.cpp index 91ae0a1d71..fb69a8c4f4 100644 --- a/platform/default/src/mbgl/storage/main_resource_loader.cpp +++ b/platform/default/src/mbgl/storage/main_resource_loader.cpp @@ -1,5 +1,6 @@ #include <mbgl/actor/actor.hpp> #include <mbgl/actor/scheduler.hpp> +#include <mbgl/platform/settings.hpp> #include <mbgl/storage/file_source_manager.hpp> #include <mbgl/storage/file_source_request.hpp> #include <mbgl/storage/main_resource_loader.hpp> @@ -131,7 +132,12 @@ public: onlineFileSource(std::move(onlineFileSource_)), supportsCacheOnlyRequests_(bool(databaseFileSource)), thread(std::make_unique<util::Thread<MainResourceLoaderThread>>( - "ResourceLoaderThread", assetFileSource, databaseFileSource, localFileSource, onlineFileSource)) {} + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_WORKER), + "ResourceLoaderThread", + assetFileSource, + databaseFileSource, + localFileSource, + onlineFileSource)) {} std::unique_ptr<AsyncRequest> request(const Resource& resource, Callback callback) { auto req = std::make_unique<FileSourceRequest>(std::move(callback)); diff --git a/platform/default/src/mbgl/storage/online_file_source.cpp b/platform/default/src/mbgl/storage/online_file_source.cpp index 0f5b438e1d..37b1f7ca8e 100644 --- a/platform/default/src/mbgl/storage/online_file_source.cpp +++ b/platform/default/src/mbgl/storage/online_file_source.cpp @@ -1,8 +1,8 @@ -#include <mbgl/storage/online_file_source.hpp> +#include <mbgl/platform/settings.hpp> +#include <mbgl/storage/file_source_request.hpp> #include <mbgl/storage/http_file_source.hpp> #include <mbgl/storage/network_status.hpp> - -#include <mbgl/storage/file_source_request.hpp> +#include <mbgl/storage/online_file_source.hpp> #include <mbgl/storage/resource_transform.hpp> #include <mbgl/storage/response.hpp> #include <mbgl/util/logging.hpp> @@ -15,6 +15,7 @@ #include <mbgl/util/http_timeout.hpp> #include <mbgl/util/mapbox.hpp> #include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/platform.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/util/thread.hpp> #include <mbgl/util/timer.hpp> @@ -293,7 +294,9 @@ private: class OnlineFileSource::Impl { public: - Impl() : thread(std::make_unique<util::Thread<OnlineFileSourceThread>>("OnlineFileSource")) {} + Impl() + : thread(std::make_unique<util::Thread<OnlineFileSourceThread>>( + util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_NETWORK), "OnlineFileSource")) {} std::unique_ptr<AsyncRequest> request(Callback callback, Resource res) { auto req = std::make_unique<FileSourceRequest>(std::move(callback)); |