summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-22 13:16:21 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-22 20:58:51 +0100
commit3bc79e316e343d59f77811bca4ed6c594431e91c (patch)
tree2d0b7e5f49e65f905f5dad38d471cb272092e2c8 /platform
parent67ed3ae3eb25e5bb0ec2d0369d042438bd9b2c7f (diff)
downloadqtlocation-mapboxgl-3bc79e316e343d59f77811bca4ed6c594431e91c.tar.gz
[build] move default ThreadPool implementation to platform/default
Diffstat (limited to 'platform')
-rw-r--r--platform/android/config.cmake5
-rwxr-xr-xplatform/android/src/native_map_view.hpp2
-rw-r--r--platform/default/mbgl/util/default_thread_pool.cpp (renamed from platform/default/thread_pool.cpp)2
-rw-r--r--platform/default/mbgl/util/default_thread_pool.hpp27
-rw-r--r--platform/glfw/main.cpp2
-rw-r--r--platform/ios/config.cmake3
-rw-r--r--platform/ios/src/MGLMapView.mm2
-rw-r--r--platform/linux/config.cmake3
-rw-r--r--platform/macos/config.cmake3
-rw-r--r--platform/macos/src/MGLMapView.mm2
-rw-r--r--platform/qt/qt.cmake3
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp2
12 files changed, 44 insertions, 12 deletions
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index 1af81d6841..5e37d13e60 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -56,11 +56,12 @@ macro(mbgl_platform_core)
# TODO
# Thread pool
- PRIVATE platform/default/thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
)
target_include_directories(mbgl-core
- PRIVATE platform/default
+ PUBLIC platform/default
)
target_add_mason_package(mbgl-core PUBLIC sqlite)
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 14b9842c72..35c0307539 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -4,7 +4,7 @@
#include <mbgl/map/view.hpp>
#include <mbgl/map/backend.hpp>
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/platform/default/thread_pool.hpp>
+#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <string>
diff --git a/platform/default/thread_pool.cpp b/platform/default/mbgl/util/default_thread_pool.cpp
index b7e02db157..92c0f06745 100644
--- a/platform/default/thread_pool.cpp
+++ b/platform/default/mbgl/util/default_thread_pool.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/thread_pool.hpp>
+#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/actor/mailbox.hpp>
namespace mbgl {
diff --git a/platform/default/mbgl/util/default_thread_pool.hpp b/platform/default/mbgl/util/default_thread_pool.hpp
new file mode 100644
index 0000000000..a14d16d771
--- /dev/null
+++ b/platform/default/mbgl/util/default_thread_pool.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <mbgl/actor/scheduler.hpp>
+
+#include <condition_variable>
+#include <mutex>
+#include <queue>
+#include <thread>
+
+namespace mbgl {
+
+class ThreadPool : public Scheduler {
+public:
+ ThreadPool(std::size_t count);
+ ~ThreadPool() override;
+
+ void schedule(std::weak_ptr<Mailbox>) override;
+
+private:
+ std::vector<std::thread> threads;
+ std::queue<std::weak_ptr<Mailbox>> queue;
+ std::mutex mutex;
+ std::condition_variable cv;
+ bool terminate { false };
+};
+
+} // namespace mbgl
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 6e4b324c43..e3c36dfbb8 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -4,7 +4,7 @@
#include <mbgl/util/default_styles.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/platform/platform.hpp>
-#include <mbgl/platform/default/thread_pool.hpp>
+#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <signal.h>
diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake
index a24d70fd81..56cb5344ae 100644
--- a/platform/ios/config.cmake
+++ b/platform/ios/config.cmake
@@ -48,7 +48,8 @@ macro(mbgl_platform_core)
PRIVATE platform/default/offscreen_view.cpp
# Thread pool
- PRIVATE platform/default/thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
)
target_add_mason_package(mbgl-core PUBLIC geojson)
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 45ff2f826f..be4e25b46e 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -14,7 +14,7 @@
#include <mbgl/map/mode.hpp>
#include <mbgl/platform/platform.hpp>
#include <mbgl/storage/reachability.h>
-#include <mbgl/platform/default/thread_pool.hpp>
+#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
#include <mbgl/style/transition_options.hpp>
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index 94830e6d26..312577a185 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -82,7 +82,8 @@ macro(mbgl_platform_core)
PRIVATE platform/default/offscreen_view.cpp
# Thread pool
- PRIVATE platform/default/thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
)
target_include_directories(mbgl-core
diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake
index b608d3b2dd..13b434117f 100644
--- a/platform/macos/config.cmake
+++ b/platform/macos/config.cmake
@@ -48,7 +48,8 @@ macro(mbgl_platform_core)
PRIVATE platform/default/offscreen_view.cpp
# Thread pool
- PRIVATE platform/default/thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
)
target_add_mason_package(mbgl-core PUBLIC geojson)
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 288ed68d62..0feaa3d306 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -22,7 +22,7 @@
#import <mbgl/annotation/annotation.hpp>
#import <mbgl/map/camera.hpp>
#import <mbgl/storage/reachability.h>
-#import <mbgl/platform/default/thread_pool.hpp>
+#import <mbgl/util/default_thread_pool.hpp>
#import <mbgl/gl/extension.hpp>
#import <mbgl/gl/context.hpp>
#import <mbgl/map/backend.hpp>
diff --git a/platform/qt/qt.cmake b/platform/qt/qt.cmake
index 76c1d691d0..cb284afcf3 100644
--- a/platform/qt/qt.cmake
+++ b/platform/qt/qt.cmake
@@ -31,7 +31,8 @@ set(MBGL_QT_FILES
PRIVATE platform/default/log_stderr.cpp
# Thread pool
- PRIVATE platform/default/thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
+ PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
# Platform integration
PRIVATE platform/qt/src/async_task.cpp
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index e7a14601c1..edff728dd4 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -5,7 +5,7 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/backend.hpp>
#include <mbgl/map/view.hpp>
-#include <mbgl/platform/default/thread_pool.hpp>
+#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/geo.hpp>