summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-03-05 01:02:33 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-05-10 14:20:38 +0300
commitcf08f6428af4b772ba0e830a0a73a150a0b9d641 (patch)
tree5730ad8c952b14f1da012cf773499f9111d36f95
parent06f1dc48a2fb317979ab48ce323115be5bd48f16 (diff)
downloadqtlocation-mapboxgl-cf08f6428af4b772ba0e830a0a73a150a0b9d641.tar.gz
[node] Remove NodeThreadPool
Simplify, use the default thread pool, less platform abstraction.
-rw-r--r--cmake/node.cmake2
-rw-r--r--platform/node/src/node_thread_pool.cpp49
-rw-r--r--platform/node/src/node_thread_pool.hpp37
3 files changed, 0 insertions, 88 deletions
diff --git a/cmake/node.cmake b/cmake/node.cmake
index e3d5ac9d21..a791d99b42 100644
--- a/cmake/node.cmake
+++ b/cmake/node.cmake
@@ -41,8 +41,6 @@ target_sources(mbgl-node INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_request.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_feature.hpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_feature.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_thread_pool.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_thread_pool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_expression.hpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_expression.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/util/async_queue.hpp
diff --git a/platform/node/src/node_thread_pool.cpp b/platform/node/src/node_thread_pool.cpp
deleted file mode 100644
index de403c605c..0000000000
--- a/platform/node/src/node_thread_pool.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "node_thread_pool.hpp"
-#include "util/async_queue.hpp"
-
-#include <mbgl/actor/mailbox.hpp>
-#include <mbgl/platform/background_scheduler.hpp>
-
-namespace node_mbgl {
-
-NodeThreadPool::NodeThreadPool()
- : queue(new util::AsyncQueue<std::weak_ptr<mbgl::Mailbox>>(uv_default_loop(), [](std::weak_ptr<mbgl::Mailbox> mailbox) {
- Worker* worker = new Worker(mailbox);
- Nan::AsyncQueueWorker(worker);
- })) {
- // Don't keep the event loop alive.
- queue->unref();
-}
-
-NodeThreadPool::~NodeThreadPool() {
- queue->stop();
-}
-
-void NodeThreadPool::schedule(std::weak_ptr<mbgl::Mailbox> mailbox) {
- queue->send(std::move(mailbox));
-}
-
-NodeThreadPool::Worker::Worker(std::weak_ptr<mbgl::Mailbox> mailbox_)
- : AsyncWorker(nullptr),
- mailbox(std::move(mailbox_)) {};
-
-void NodeThreadPool::Worker::Execute() {
- mbgl::Mailbox::maybeReceive(mailbox);
-}
-
-void NodeThreadPool::Worker::WorkComplete() {
- // no-op to avoid calling nullptr callback
-}
-
-} // namespace node_mbgl
-
-namespace mbgl {
-namespace platform {
-
-Scheduler& GetBackgroundScheduler() {
- static node_mbgl::NodeThreadPool pool;
- return pool;
-}
-
-} // namespace platform
-} // namespace mbgl
diff --git a/platform/node/src/node_thread_pool.hpp b/platform/node/src/node_thread_pool.hpp
deleted file mode 100644
index d412e53d3d..0000000000
--- a/platform/node/src/node_thread_pool.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-
-#include <mbgl/actor/scheduler.hpp>
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wshadow"
-#include <nan.h>
-#pragma GCC diagnostic pop
-
-namespace node_mbgl {
-
-namespace util { template <typename T> class AsyncQueue; }
-
-class NodeThreadPool : public mbgl::Scheduler {
-public:
- NodeThreadPool();
- ~NodeThreadPool();
-
- void schedule(std::weak_ptr<mbgl::Mailbox>) override;
-
-private:
- util::AsyncQueue<std::weak_ptr<mbgl::Mailbox>>* queue;
-
- class Worker : public Nan::AsyncWorker {
- public:
- Worker(std::weak_ptr<mbgl::Mailbox>);
-
- void Execute();
- void WorkComplete();
-
- private:
- std::weak_ptr<mbgl::Mailbox> mailbox;
- };
-};
-
-} // namespace node_mbgl