summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2020-03-12 00:28:45 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2020-03-12 13:35:45 +0200
commit461c4147481f12c3d22bfe7cb6932972a5ef0c9e (patch)
tree395ce6193cfe30a1bf046009ab656a1f1a0d77f1
parent639434b3efd144b465f2dd118cb3b9acce2b6b31 (diff)
downloadqtlocation-mapboxgl-461c4147481f12c3d22bfe7cb6932972a5ef0c9e.tar.gz
[core] Follow-up on the platform integration callback PR
Addressing review comments that arrived after the PR was merged.
-rw-r--r--include/mbgl/util/run_loop.hpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index c89b8bd795..4bf614c55f 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -48,14 +48,12 @@ public:
void runOnce();
void stop();
- using PlatformCallback = std::function<void()>;
-
// Platform integration callback for platforms that do not have full
// run loop integration or don't want to block at the Mapbox GL Native
// loop. It will be called from any thread and is up to the platform
// to, after receiving the callback, call RunLoop::runOnce() from the
// same thread as the Map object lives.
- void setPlatformCallback(PlatformCallback&& callback) { platformCallback = std::move(callback); }
+ void setPlatformCallback(std::function<void()> callback) { platformCallback = std::move(callback); }
// So far only needed by the libcurl backend.
void addWatch(int fd, Event, std::function<void(int, Event)>&& callback);
@@ -104,7 +102,10 @@ private:
defaultQueue.emplace(std::move(task));
}
wake();
- platformCallback();
+
+ if (platformCallback) {
+ platformCallback();
+ }
}
void process() {
@@ -127,7 +128,7 @@ private:
}
}
- PlatformCallback platformCallback = [] {};
+ std::function<void()> platformCallback;
Queue defaultQueue;
Queue highPriorityQueue;