[node] Need to have a singleton RunLoop instance
This commit is contained in:
@@ -6,11 +6,26 @@
|
||||
#include <nan.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "node_mapbox_gl_native.hpp"
|
||||
#include "node_map.hpp"
|
||||
#include "node_log.hpp"
|
||||
#include "node_request.hpp"
|
||||
|
||||
namespace node_mbgl {
|
||||
|
||||
mbgl::util::RunLoop& NodeRunLoop() {
|
||||
static mbgl::util::RunLoop nodeRunLoop(uv_default_loop());
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user