summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-06-03 16:40:15 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-06-06 22:19:25 +0300
commit7b8698b47a0ff5c4adaf474e47f89434f287f183 (patch)
tree410f69ee4d1161157b788409744d6391da54492e /include
parent874fa41c128c2c3c7e075b0dcde727d6cf678866 (diff)
downloadqtlocation-mapboxgl-7b8698b47a0ff5c4adaf474e47f89434f287f183.tar.gz
[core] Naive atomic type for ARMv5
std::atomic<bool> is implemented lock free which doesn't work on ARMv5 and seems like the compiler is generating bogus code. This workaround is a naive implementation using regular mutexes.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/storage/network_status.hpp5
-rw-r--r--include/mbgl/util/run_loop.hpp10
2 files changed, 8 insertions, 7 deletions
diff --git a/include/mbgl/storage/network_status.hpp b/include/mbgl/storage/network_status.hpp
index d7f502a3b2..1b5471a44e 100644
--- a/include/mbgl/storage/network_status.hpp
+++ b/include/mbgl/storage/network_status.hpp
@@ -1,6 +1,7 @@
#pragma once
-#include <atomic>
+#include <mbgl/util/atomic.hpp>
+
#include <mutex>
#include <set>
@@ -26,7 +27,7 @@ public:
static void Unsubscribe(util::AsyncTask* async);
private:
- static std::atomic<bool> online;
+ static util::Atomic<bool> online;
static std::mutex mtx;
static std::set<util::AsyncTask*> observers;
};
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index 9703fe7bcb..56965c97e6 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <mbgl/util/atomic.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/util.hpp>
#include <mbgl/util/work_task.hpp>
@@ -9,7 +10,6 @@
#include <utility>
#include <queue>
#include <mutex>
-#include <atomic>
namespace mbgl {
namespace util {
@@ -59,7 +59,7 @@ public:
template <class Fn, class... Args>
std::unique_ptr<AsyncRequest>
invokeCancellable(Fn&& fn, Args&&... args) {
- auto flag = std::make_shared<std::atomic<bool>>();
+ auto flag = std::make_shared<util::Atomic<bool>>();
*flag = false;
auto tuple = std::make_tuple(std::move(args)...);
@@ -77,7 +77,7 @@ public:
template <class Fn, class Cb, class... Args>
std::unique_ptr<AsyncRequest>
invokeWithCallback(Fn&& fn, Cb&& callback, Args&&... args) {
- auto flag = std::make_shared<std::atomic<bool>>();
+ auto flag = std::make_shared<util::Atomic<bool>>();
*flag = false;
// Create a lambda L1 that invokes another lambda L2 on the current RunLoop R, that calls
@@ -114,7 +114,7 @@ private:
template <class F, class P>
class Invoker : public WorkTask {
public:
- Invoker(F&& f, P&& p, std::shared_ptr<std::atomic<bool>> canceled_ = nullptr)
+ Invoker(F&& f, P&& p, std::shared_ptr<util::Atomic<bool>> canceled_ = nullptr)
: canceled(std::move(canceled_)),
func(std::move(f)),
params(std::move(p)) {
@@ -148,7 +148,7 @@ private:
}
std::recursive_mutex mutex;
- std::shared_ptr<std::atomic<bool>> canceled;
+ std::shared_ptr<util::Atomic<bool>> canceled;
F func;
P params;