summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-29 14:54:52 +0200
committerJuha Alanen <juha.alanen@mapbox.com>2019-11-29 15:37:49 +0200
commit3947d5fa98263d3b2b4b319b4f6629daca8c91ff (patch)
tree6df47ea1d010a6ef73d72c67c9098376a9f1a979
parent2e93f1e9823f0994224d6fd6836987a0e5b2d7ff (diff)
downloadqtlocation-mapboxgl-3947d5fa98263d3b2b4b319b4f6629daca8c91ff.tar.gz
[core] Retain thread pool in GeoJSONSource
Otherwise, the construction of the `Immutable<Source::Impl>` in background thread might never yeld.
-rw-r--r--include/mbgl/style/sources/geojson_source.hpp3
-rw-r--r--src/mbgl/style/sources/geojson_source.cpp4
2 files changed, 4 insertions, 3 deletions
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp
index 9569b61df4..df2f9d2daf 100644
--- a/include/mbgl/style/sources/geojson_source.hpp
+++ b/include/mbgl/style/sources/geojson_source.hpp
@@ -14,7 +14,7 @@
namespace mbgl {
class AsyncRequest;
-
+class Scheduler;
namespace style {
struct GeoJSONOptions {
@@ -81,6 +81,7 @@ public:
private:
optional<std::string> url;
std::unique_ptr<AsyncRequest> req;
+ std::shared_ptr<Scheduler> threadPool;
mapbox::base::WeakPtrFactory<Source> weakFactory {this};
};
diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp
index fc8a563fd4..ea6fb5cc68 100644
--- a/src/mbgl/style/sources/geojson_source.cpp
+++ b/src/mbgl/style/sources/geojson_source.cpp
@@ -19,7 +19,7 @@ Immutable<GeoJSONOptions> GeoJSONOptions::defaultOptions() {
}
GeoJSONSource::GeoJSONSource(std::string id, Immutable<GeoJSONOptions> options)
- : Source(makeMutable<Impl>(std::move(id), std::move(options))) {}
+ : Source(makeMutable<Impl>(std::move(id), std::move(options))), threadPool(Scheduler::GetBackground()) {}
GeoJSONSource::~GeoJSONSource() = default;
@@ -98,7 +98,7 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) {
loaded = true;
observer->onSourceLoaded(*this);
};
- Scheduler::GetBackground()->scheduleAndReplyValue(makeImplInBackground, onImplReady);
+ threadPool->scheduleAndReplyValue(makeImplInBackground, onImplReady);
}
});
}