diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 9a883ba96de..e73876b429a 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -13,19 +13,12 @@ namespace mbgl { namespace style { -class GeoJSONVTData : public GeoJSONData, public std::enable_shared_from_this { +class GeoJSONVTData : public GeoJSONData { public: void getTile(const CanonicalTileID& id, const std::function& fn) final { assert(fn); - std::weak_ptr weak = shared_from_this(); scheduler->scheduleAndReplyValue( - [id, weak, this]() -> TileFeatures { - if (auto self = weak.lock()) { - return impl.getTile(id.z, id.x, id.y).features; - } - return {}; - }, - fn); + [id, impl = this->impl]() -> TileFeatures { return impl->getTile(id.z, id.x, id.y).features; }, fn); } Features getChildren(const std::uint32_t) final { return {}; } @@ -39,8 +32,10 @@ class GeoJSONVTData : public GeoJSONData, public std::enable_shared_from_this(geoJSON, options)), + scheduler(Scheduler::GetSequenced()) {} + + std::shared_ptr impl; // Accessed on worker thread. std::shared_ptr scheduler; }; diff --git a/src/mbgl/util/thread_pool.hpp b/src/mbgl/util/thread_pool.hpp index e39c1abc736..9791ff94601 100644 --- a/src/mbgl/util/thread_pool.hpp +++ b/src/mbgl/util/thread_pool.hpp @@ -48,6 +48,7 @@ class ThreadedScheduler : public ThreadedSchedulerBase { ~ThreadedScheduler() override { terminate(); for (auto& thread : threads) { + assert(std::this_thread::get_id() != thread.get_id()); thread.join(); } }