From cf08f6428af4b772ba0e830a0a73a150a0b9d641 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 5 Mar 2019 01:02:33 +0200 Subject: [node] Remove NodeThreadPool Simplify, use the default thread pool, less platform abstraction. --- cmake/node.cmake | 2 -- platform/node/src/node_thread_pool.cpp | 49 ---------------------------------- platform/node/src/node_thread_pool.hpp | 37 ------------------------- 3 files changed, 88 deletions(-) delete mode 100644 platform/node/src/node_thread_pool.cpp delete mode 100644 platform/node/src/node_thread_pool.hpp 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 -#include - -namespace node_mbgl { - -NodeThreadPool::NodeThreadPool() - : queue(new util::AsyncQueue>(uv_default_loop(), [](std::weak_ptr 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 mailbox) { - queue->send(std::move(mailbox)); -} - -NodeThreadPool::Worker::Worker(std::weak_ptr 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 - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#pragma GCC diagnostic ignored "-Wshadow" -#include -#pragma GCC diagnostic pop - -namespace node_mbgl { - -namespace util { template class AsyncQueue; } - -class NodeThreadPool : public mbgl::Scheduler { -public: - NodeThreadPool(); - ~NodeThreadPool(); - - void schedule(std::weak_ptr) override; - -private: - util::AsyncQueue>* queue; - - class Worker : public Nan::AsyncWorker { - public: - Worker(std::weak_ptr); - - void Execute(); - void WorkComplete(); - - private: - std::weak_ptr mailbox; - }; -}; - -} // namespace node_mbgl -- cgit v1.2.1