summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-06-06 16:18:46 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-06-06 22:19:25 +0300
commit874fa41c128c2c3c7e075b0dcde727d6cf678866 (patch)
tree9f7959c13c69e4a4a24fa2250c06d231e4a4e462 /platform
parentc3cbe67c018a2431140babf2b8ba4c403e5e429f (diff)
downloadqtlocation-mapboxgl-874fa41c128c2c3c7e075b0dcde727d6cf678866.tar.gz
[android] Do not use lock-free types on Android
They are not supported by ARMv5 and the compiler is generating bogus code. std::atomic might be implemented lock-free for some types, but we are going to introduce a naive polyfill to make sure that doesn't happen on ARMv5 (only).
Diffstat (limited to 'platform')
-rw-r--r--platform/android/src/async_task.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/platform/android/src/async_task.cpp b/platform/android/src/async_task.cpp
index 4a68c1c093..7b78eadb0c 100644
--- a/platform/android/src/async_task.cpp
+++ b/platform/android/src/async_task.cpp
@@ -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
+ std::atomic<bool> queued;
std::function<void()> task;
};