diff options
Diffstat (limited to 'src/mbgl/map/tile_data.hpp')
-rw-r--r-- | src/mbgl/map/tile_data.hpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mbgl/map/tile_data.hpp b/src/mbgl/map/tile_data.hpp index 57f7c30ff3..7f16e7c413 100644 --- a/src/mbgl/map/tile_data.hpp +++ b/src/mbgl/map/tile_data.hpp @@ -49,10 +49,24 @@ public: void cancel(); const std::string toString() const; - inline bool ready() const { + inline bool isReady() const { return isReadyState(state); } + // Returns true if the TileData is in a final state and we cannot + // make changes to it anymore. + inline bool isImmutable() const { + return state == State::parsed || state == State::obsolete; + } + + // We let subclasses override setState() so they + // can intercept the state change and react accordingly. + virtual void setState(const State& state); + + inline State getState() const { + return state; + } + void endParsing(); // Override this in the child class. @@ -61,7 +75,6 @@ public: const TileID id; const std::string name; - std::atomic<State> state; std::atomic_flag parsing = ATOMIC_FLAG_INIT; protected: @@ -81,6 +94,10 @@ protected: std::unique_ptr<WorkRequest> workRequest; +private: + std::atomic<State> state; + +protected: // Contains the tile ID string for painting debug information. DebugFontBuffer debugFontBuffer; |