diff options
Diffstat (limited to 'include/mbgl/util/run_loop.hpp')
-rw-r--r-- | include/mbgl/util/run_loop.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp index 5cde95a531..c89b8bd795 100644 --- a/include/mbgl/util/run_loop.hpp +++ b/include/mbgl/util/run_loop.hpp @@ -48,6 +48,15 @@ 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); } + // So far only needed by the libcurl backend. void addWatch(int fd, Event, std::function<void(int, Event)>&& callback); void removeWatch(int fd); @@ -95,6 +104,7 @@ private: defaultQueue.emplace(std::move(task)); } wake(); + platformCallback(); } void process() { @@ -117,6 +127,8 @@ private: } } + PlatformCallback platformCallback = [] {}; + Queue defaultQueue; Queue highPriorityQueue; std::mutex mutex; |