Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Retain thread pool in GeoJSONSource
Browse files Browse the repository at this point in the history
Otherwise, the construction of the `Immutable<Source::Impl>` in background thread might never yeld.
  • Loading branch information
pozdnyakov authored and Juha Alanen committed Nov 29, 2019
1 parent 2e93f1e commit 3947d5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/mbgl/style/sources/geojson_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace mbgl {

class AsyncRequest;

class Scheduler;
namespace style {

struct GeoJSONOptions {
Expand Down Expand Up @@ -81,6 +81,7 @@ class GeoJSONSource final : public Source {
private:
optional<std::string> url;
std::unique_ptr<AsyncRequest> req;
std::shared_ptr<Scheduler> threadPool;
mapbox::base::WeakPtrFactory<Source> weakFactory {this};
};

Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/style/sources/geojson_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -98,7 +98,7 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) {
loaded = true;
observer->onSourceLoaded(*this);
};
Scheduler::GetBackground()->scheduleAndReplyValue(makeImplInBackground, onImplReady);
threadPool->scheduleAndReplyValue(makeImplInBackground, onImplReady);
}
});
}
Expand Down

0 comments on commit 3947d5f

Please sign in to comment.