From f726a48f52c77d8259687f0e47a9f6c9f40e47b3 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 12 Mar 2020 00:28:45 +0200 Subject: [core] Follow-up on the platform integration callback PR Addressing review comments that arrived after the PR was merged. --- include/mbgl/util/run_loop.hpp | 11 ++++++----- 1 file 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; - // 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 callback) { platformCallback = std::move(callback); } // So far only needed by the libcurl backend. void addWatch(int fd, Event, std::function&& 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 platformCallback; Queue defaultQueue; Queue highPriorityQueue; -- cgit v1.2.1