[core] Retain thread pool in GeoJSONSource

Otherwise, the construction of the `Immutable<Source::Impl>` in background thread might never yeld.
This commit is contained in:
Mikhail Pozdnyakov
2019-11-29 14:54:52 +02:00
committed by Juha Alanen
parent 2e93f1e982
commit 3947d5fa98
2 changed files with 4 additions and 3 deletions

View File

@@ -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};
};

View File

@@ -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);
}
});
}