summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/annotation_manager.hpp
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-02-27 11:46:17 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-03-05 17:43:37 +0200
commit81e116d41a4ea1e3ed0d5e91e06541c3e8855a09 (patch)
tree79cdee7e5a4ffda6fafcb9f4fce39b5b87682385 /src/mbgl/annotation/annotation_manager.hpp
parentc5155dcf334a5c5125c065e4447cb8b30989e5e5 (diff)
downloadqtlocation-mapboxgl-81e116d41a4ea1e3ed0d5e91e06541c3e8855a09.tar.gz
[core] Use weak annotation manager
Map and renderer / orchestrator should be able to run on a separate threads, however, legacy AnnotationManager is shared between Map and Renderer, therefore is not a thread safe. Until AnnotationManager is deprecated and removed from a code-base, use it only via weak pointers.
Diffstat (limited to 'src/mbgl/annotation/annotation_manager.hpp')
-rw-r--r--src/mbgl/annotation/annotation_manager.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp
index 6c794d7f84..a9389d8ca9 100644
--- a/src/mbgl/annotation/annotation_manager.hpp
+++ b/src/mbgl/annotation/annotation_manager.hpp
@@ -11,6 +11,8 @@
#include <unordered_set>
#include <unordered_map>
+#include <mapbox/weak.hpp>
+
namespace mbgl {
class LatLngBounds;
@@ -48,6 +50,8 @@ public:
static const std::string PointLayerID;
static const std::string ShapeLayerID;
+ mapbox::base::WeakPtr<AnnotationManager> makeWeakPtr() { return weakFactory.makeWeakPtr(); }
+
private:
void add(const AnnotationID&, const SymbolAnnotation&);
void add(const AnnotationID&, const LineAnnotation&);
@@ -84,6 +88,7 @@ private:
ImageMap images;
std::unordered_set<AnnotationTile*> tiles;
+ mapbox::base::WeakPtrFactory<AnnotationManager> weakFactory{this};
};
} // namespace mbgl