diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-11 01:31:13 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-11 12:35:20 +0200 |
commit | 410e583db6459d9eeb672dd3dbae739b5069b04a (patch) | |
tree | 8e3edbf8307f7c6bc535fc61e94967fee2e29520 /include/mbgl | |
parent | 09ab9420a9834788708a90a9767202423abf6a5a (diff) | |
download | qtlocation-mapboxgl-410e583db6459d9eeb672dd3dbae739b5069b04a.tar.gz |
[core] Add a callback for platform RunLoop integration
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.
Diffstat (limited to 'include/mbgl')
-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; |