diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-04-09 14:22:54 +0200 |
---|---|---|
committer | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-04-09 14:22:54 +0200 |
commit | a039c7915e077a92c74a247a37d935ebee1b83a6 (patch) | |
tree | dc694224b856cf76786fc13f6c0664aca07e12f7 | |
parent | 2ee342448bc6679ef6735ea0deb23f21dcf7c78b (diff) | |
download | qtlocation-mapboxgl-upstream/lp-designated-gejson-conversion-thread.tar.gz |
[android] use a designated thread for GeoJSONSource features conversionupstream/lp-designated-gejson-conversion-thread
-rw-r--r-- | platform/android/src/style/sources/geojson_source.cpp | 11 | ||||
-rw-r--r-- | platform/android/src/style/sources/geojson_source.hpp | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp index a9307afe67..bf4f95e4c4 100644 --- a/platform/android/src/style/sources/geojson_source.cpp +++ b/platform/android/src/style/sources/geojson_source.cpp @@ -17,7 +17,6 @@ #include "../conversion/url_or_tileset.hpp" #include <string> -#include <mbgl/util/shared_thread_pool.hpp> // GeoJSONSource uses a "coalescing" model for high frequency asynchronous data update calls, // which in practice means, that any update that started processing is going to finish @@ -48,16 +47,14 @@ namespace android { : Source(env, std::make_unique<mbgl::style::GeoJSONSource>( jni::Make<std::string>(env, sourceId), convertGeoJSONOptions(env, options))) - , threadPool(sharedThreadPool()) - , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) { + , converter(std::make_unique<util::Thread<FeatureConverter>>("GeoJSONSource")) { } GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend& frontend) : Source(env, coreSource, createJavaPeer(env), frontend) - , threadPool(sharedThreadPool()) - , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) { + , converter(std::make_unique<util::Thread<FeatureConverter>>("GeoJSONSource")) { } GeoJSONSource::~GeoJSONSource() = default; @@ -67,7 +64,7 @@ namespace android { std::shared_ptr<std::string> json = std::make_shared<std::string>(jni::Make<std::string>(env, jString)); Update::Converter converterFn = [this, json](ActorRef<Callback> _callback) { - converter->self().invoke(&FeatureConverter::convertJson, json, _callback); + converter->actor().invoke(&FeatureConverter::convertJson, json, _callback); }; setAsync(converterFn); @@ -170,7 +167,7 @@ namespace android { auto object = std::make_shared<decltype(global)>(std::move(global)); Update::Converter converterFn = [this, object](ActorRef<Callback> _callback) { - converter->self().invoke(&FeatureConverter::convertObject<JNIType>, object, _callback); + converter->actor().invoke(&FeatureConverter::convertObject<JNIType>, object, _callback); }; setAsync(converterFn); diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp index e737e41924..fcfbf06f38 100644 --- a/platform/android/src/style/sources/geojson_source.hpp +++ b/platform/android/src/style/sources/geojson_source.hpp @@ -7,6 +7,7 @@ #include "../../geojson/feature_collection.hpp" #include "../../android_renderer_frontend.hpp" #include <jni/jni.hpp> +#include <mbgl/util/thread.hpp> namespace mbgl { namespace android { @@ -59,8 +60,7 @@ private: jni::Local<jni::Object<Source>> createJavaPeer(jni::JNIEnv&); std::unique_ptr<Update> awaitingUpdate; std::unique_ptr<Update> update; - std::shared_ptr<ThreadPool> threadPool; - std::unique_ptr<Actor<FeatureConverter>> converter; + std::unique_ptr<util::Thread<FeatureConverter>> converter; template <class JNIType> void setCollectionAsync(jni::JNIEnv&, const jni::Object<JNIType>&); |