summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2018-10-25 16:33:09 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2018-11-02 15:46:17 +0200
commit9618b8cf92a037aaced382892106350ddf67ffa3 (patch)
tree9ec34c9ad87595b2e73c378718e0ba3040f083cb
parent37a4967149a8ff8aca38e3adf56dfa4aa6971798 (diff)
downloadqtlocation-mapboxgl-9618b8cf92a037aaced382892106350ddf67ffa3.tar.gz
wip
-rw-r--r--include/mbgl/platform/factory.hpp29
-rw-r--r--include/mbgl/platform/platform_run_loop.hpp17
-rw-r--r--include/mbgl/util/run_loop.hpp10
3 files changed, 50 insertions, 6 deletions
diff --git a/include/mbgl/platform/factory.hpp b/include/mbgl/platform/factory.hpp
new file mode 100644
index 0000000000..d8615b424f
--- /dev/null
+++ b/include/mbgl/platform/factory.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <memory>
+
+namespace mbgl {
+
+/**
+ * @brief A factory class for platform dependent code.
+ *
+ * These symbols are weak and should be provided at
+ * linking time by the platform linking with Mapbox GL
+ * core library.
+ */
+class PlatformFactory {
+public:
+ /**
+ * @brief Creates a new PlatformRunLoop object.
+ *
+ * A platform specific run loop that can sleep,
+ * process tasks, wake-up in a thread safe-way.
+ *
+ * @return the platform run loop.
+ */
+ static std::unique_ptr<PlatformRunLoop> runLoop();
+
+ PlatformFactory() = delete;
+}
+
+} // namespace mbgl
diff --git a/include/mbgl/platform/platform_run_loop.hpp b/include/mbgl/platform/platform_run_loop.hpp
new file mode 100644
index 0000000000..c3b3d4c198
--- /dev/null
+++ b/include/mbgl/platform/platform_run_loop.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <mbgl/util/run_loop.hpp>
+
+namespace mbgl {
+
+class PlatformRunLoop
+public:
+ virtual void run() = 0;
+ virtual void runOnce() = 0;
+ virtual void stop() = 0;
+
+ virtual void addWatch(int fd, Event, std::function<void(int, util::RunLoop::Event)>&& callback) = 0;
+ virtual void removeWatch(int fd) = 0;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp
index 381e3ae213..c719f978ed 100644
--- a/include/mbgl/util/run_loop.hpp
+++ b/include/mbgl/util/run_loop.hpp
@@ -14,9 +14,10 @@
#include <mutex>
namespace mbgl {
-namespace util {
-using LOOP_HANDLE = void *;
+class PlatformRunLoop;
+
+namespace util {
class RunLoop : public Scheduler,
private util::noncopyable {
@@ -42,7 +43,6 @@ public:
~RunLoop() override;
static RunLoop* Get();
- static LOOP_HANDLE getLoopHandle();
void run();
void runOnce();
@@ -79,8 +79,6 @@ public:
});
}
- class Impl;
-
private:
MBGL_STORE_THREAD(tid)
@@ -124,7 +122,7 @@ private:
Queue highPriorityQueue;
std::mutex mutex;
- std::unique_ptr<Impl> impl;
+ std::unique_ptr<PlatformRunLoop> impl;
};
} // namespace util