diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-03-26 19:35:08 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-03-27 12:56:41 +0100 |
commit | a2629393b39f3950e172d3c6c258ed5f7cf2aa4f (patch) | |
tree | d93e4aaaed01be9c2a15a47884a8050304f3a14e /include/mbgl/map/map.hpp | |
parent | 177a97aaf295295eb5528a64df4a664c59ea5c2f (diff) | |
download | qtlocation-mapboxgl-a2629393b39f3950e172d3c6c258ed5f7cf2aa4f.tar.gz |
dispatch all AnnotationManager calls to the map thread
calls that return a value block until the operation was executed
Diffstat (limited to 'include/mbgl/map/map.hpp')
-rw-r--r-- | include/mbgl/map/map.hpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index cb93916284..4ce7014307 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -15,6 +15,7 @@ #include <iosfwd> #include <set> #include <vector> +#include <queue> #include <mutex> #include <condition_variable> #include <functional> @@ -159,8 +160,8 @@ public: const std::vector<std::string>& symbols); void removeAnnotation(uint32_t); void removeAnnotations(const std::vector<uint32_t>&); - std::vector<uint32_t> getAnnotationsInBounds(const LatLngBounds&) const; - LatLngBounds getBoundsForAnnotations(const std::vector<uint32_t>&) const; + std::vector<uint32_t> getAnnotationsInBounds(const LatLngBounds&); + LatLngBounds getBoundsForAnnotations(const std::vector<uint32_t>&); // Debug void setDebug(bool value); @@ -200,6 +201,12 @@ private: // the stylesheet. void prepare(); + // Runs the function in the map thread. + void invokeTask(std::function<void()>&&); + template <typename Fn> auto invokeSyncTask(const Fn& fn) -> decltype(fn()); + + void processTasks(); + void updateAnnotationTiles(const std::vector<Tile::ID>&); enum class Mode : uint8_t { @@ -219,6 +226,7 @@ private: std::thread thread; std::unique_ptr<uv::async> asyncTerminate; std::unique_ptr<uv::async> asyncUpdate; + std::unique_ptr<uv::async> asyncInvoke; std::unique_ptr<uv::async> asyncRender; bool terminating = false; @@ -257,6 +265,9 @@ private: std::set<util::ptr<StyleSource>> activeSources; std::atomic<UpdateType> updated; + + std::mutex mutexTask; + std::queue<std::function<void()>> tasks; }; } |