summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/image_manager.hpp
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-05-09 10:49:10 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-05-09 20:45:06 +0300
commita53c4593d64bbe23a34b0ade142c94d09f64b02c (patch)
tree1fd9053112a06a96ff398a4bd2cc6a0d6faea659 /src/mbgl/renderer/image_manager.hpp
parent6fa1d357b384fd347c5a7a83586cd923128ff52e (diff)
downloadqtlocation-mapboxgl-a53c4593d64bbe23a34b0ade142c94d09f64b02c.tar.gz
[core] Schedule invocation of onStyleImageMissing completion callback on the same thread
Before this change, ImageManger's 'done' callback for onStyleImageMissing observer notification that was created on renderer thread, could be called from different thread, therefore, is not thread safe. For example, on Android platform, callback was invoked from UI thread. This change makes callback to be scheduled on originating thread.
Diffstat (limited to 'src/mbgl/renderer/image_manager.hpp')
-rw-r--r--src/mbgl/renderer/image_manager.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mbgl/renderer/image_manager.hpp b/src/mbgl/renderer/image_manager.hpp
index 61f3f3c276..c2d6466b3a 100644
--- a/src/mbgl/renderer/image_manager.hpp
+++ b/src/mbgl/renderer/image_manager.hpp
@@ -15,6 +15,9 @@
namespace mbgl {
+template <class T>
+class Actor;
+
namespace gfx {
class Context;
} // namespace gfx
@@ -64,9 +67,11 @@ private:
bool loaded = false;
std::map<ImageRequestor*, ImageRequestPair> requestors;
+ using Callback = std::function<void()>;
+ using ActorCallback = Actor<Callback>;
struct MissingImageRequestPair {
ImageRequestPair pair;
- unsigned int callbacksRemaining;
+ std::map<std::string, std::unique_ptr<ActorCallback>> callbacks;
};
std::map<ImageRequestor*, MissingImageRequestPair> missingImageRequestors;
std::map<std::string, std::set<ImageRequestor*>> requestedImages;