diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-06-06 16:18:46 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-06-06 23:31:51 +0300 |
commit | b711979e328c54dbfd3240ea339a1662c7f9c808 (patch) | |
tree | fdedd9c4f9873b090f4c69ac5ab77a97ddd558c9 /platform | |
parent | f4a82bd367cc5a2134f37dec9979a7d653ef965c (diff) | |
download | qtlocation-mapboxgl-b711979e328c54dbfd3240ea339a1662c7f9c808.tar.gz |
[android] #5254 - fix ARMv5 support
Backported patches fixing ARMv5 support for issue #3985.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/src/async_task.cpp | 13 | ||||
-rw-r--r-- | platform/android/src/run_loop_impl.hpp | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/platform/android/src/async_task.cpp b/platform/android/src/async_task.cpp index 4a68c1c093..6a9263baff 100644 --- a/platform/android/src/async_task.cpp +++ b/platform/android/src/async_task.cpp @@ -1,9 +1,9 @@ #include "run_loop_impl.hpp" #include <mbgl/util/async_task.hpp> +#include <mbgl/util/atomic.hpp> #include <mbgl/util/run_loop.hpp> -#include <atomic> #include <functional> namespace mbgl { @@ -12,7 +12,7 @@ namespace util { class AsyncTask::Impl : public RunLoop::Impl::Runnable { public: Impl(std::function<void()>&& fn) - : task(std::move(fn)) { + : queued(true), task(std::move(fn)) { loop->initRunnable(this); } @@ -21,7 +21,8 @@ public: } void maySend() { - if (!queued.test_and_set()) { + if (queued) { + queued = false; loop->addRunnable(this); } } @@ -32,7 +33,7 @@ public: void runTask() override { loop->removeRunnable(this); - queued.clear(); + queued = true; task(); } @@ -42,7 +43,9 @@ private: RunLoop::Impl* loop = reinterpret_cast<RunLoop::Impl*>(RunLoop::getLoopHandle()); - std::atomic_flag queued = ATOMIC_FLAG_INIT; + // TODO: Use std::atomic_flag if we ever drop + // support for ARMv5 + util::Atomic<bool> queued; std::function<void()> task; }; diff --git a/platform/android/src/run_loop_impl.hpp b/platform/android/src/run_loop_impl.hpp index 5cf7231175..d855728b60 100644 --- a/platform/android/src/run_loop_impl.hpp +++ b/platform/android/src/run_loop_impl.hpp @@ -2,10 +2,10 @@ #include "jni.hpp" +#include <mbgl/util/atomic.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/run_loop.hpp> -#include <atomic> #include <list> #include <memory> #include <mutex> @@ -47,7 +47,7 @@ private: bool detach = false; ALooper* loop = nullptr; - std::atomic<bool> running; + util::Atomic<bool> running; std::recursive_mutex mtx; std::list<Runnable*> runnables; |