Revert "[node] Destroy the RunLoop with the last Map object"

This reverts commit 3633fd7ebd.
This commit is contained in:
Thiago Marcos P. Santos
2016-02-23 15:25:12 +02:00
parent 931ac77af4
commit 63982e0010
4 changed files with 10 additions and 18 deletions

View File

@@ -12,21 +12,19 @@
namespace node_mbgl {
std::shared_ptr<mbgl::util::RunLoop> NodeRunLoop() {
static std::weak_ptr<mbgl::util::RunLoop> nodeRunLoop;
auto loop = nodeRunLoop.lock();
if (!loop) {
loop = std::make_shared<mbgl::util::RunLoop>();
nodeRunLoop = loop;
}
return std::move(loop);
mbgl::util::RunLoop& NodeRunLoop() {
static mbgl::util::RunLoop nodeRunLoop;
return nodeRunLoop;
}
}
NAN_MODULE_INIT(RegisterModule) {
// This has the effect of:
// a) Ensuring that the static local variable is initialized before any thread contention.
// b) unreffing an async handle, which otherwise would keep the default loop running.
node_mbgl::NodeRunLoop().stop();
node_mbgl::NodeMap::Init(target);
node_mbgl::NodeRequest::Init(target);