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

[cp][core] Fix GeoJSONVTData ownership and life cycle #16108

Merged
merged 1 commit into from
Jan 9, 2020

Commits on Jan 9, 2020

  1. [core] Fix GeoJSONVTData ownership and life cycle

    Before this change, the `GeoJSONVTData` instance was retained at the scheduled
    lambda, which run on the worker thread represented by the `GeoJSONVTData::scheduler`
    class member:
    
    ```
            std::weak_ptr<GeoJSONVTData> 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);
    ```
    
    It caused program termination in case `self` turned to be the last reference to `this`,
    as the `std::thread` destructor was called from the thread it represented.
    
    Now, only the `GeoJSONVTData::impl` class member is retained.
    pozdnyakov committed Jan 9, 2020
    Configuration menu
    Copy the full SHA
    d8a36bb View commit details
    Browse the repository at this point in the history