summaryrefslogtreecommitdiff
path: root/include/mbgl/platform
diff options
context:
space:
mode:
authorMike Morris <mikemorris@users.noreply.github.com>2016-10-12 17:28:22 -0400
committerMike Morris <mikemorris@users.noreply.github.com>2016-10-20 14:37:36 -0400
commit817c26111a0d6650e7ebae73e46621626106d0a7 (patch)
tree60a5206f2f7658b06b214d9b7435a65a243d6e83 /include/mbgl/platform
parentab85fdb4524788ce7279e8ac362a0c1edbd5d5df (diff)
downloadqtlocation-mapboxgl-817c26111a0d6650e7ebae73e46621626106d0a7.tar.gz
[core] [node] pass thread pool impl to Map constructor
Updates mbgl::Map constructor usage everywhere Adds NodeThreadPool implementation using AsyncQueue to call Nan::AsyncQueueWorker from main thread
Diffstat (limited to 'include/mbgl/platform')
-rw-r--r--include/mbgl/platform/default/thread_pool.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/mbgl/platform/default/thread_pool.hpp b/include/mbgl/platform/default/thread_pool.hpp
new file mode 100644
index 0000000000..a14d16d771
--- /dev/null
+++ b/include/mbgl/platform/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