use new nan, async_resource

This commit is contained in:
Luis Blanco 2018-03-20 23:25:57 +03:00
parent 22288f55b0
commit 3a3b246806
2 changed files with 8 additions and 4 deletions

View File

@ -106,7 +106,8 @@ public:
Nan::Callback callback(Nan::New(*it)); Nan::Callback callback(Nan::New(*it));
if ( ! callback.IsEmpty() ) { if ( ! callback.IsEmpty() ) {
callback.Call(argc, argv); Nan::AsyncResource async("EventEmitter::cpp_emit()");
callback.Call(argc, argv, &async);
} }
} }
@ -128,7 +129,8 @@ public:
this->Wrap(emitter); this->Wrap(emitter);
v8::Local<v8::Value> argv[] = { emitter, JS_STR(name.c_str()), that, JS_STR(method.c_str()) }; v8::Local<v8::Value> argv[] = { emitter, JS_STR(name.c_str()), that, JS_STR(method.c_str()) };
connectorCb.Call(4, argv); Nan::AsyncResource async("EventEmitter::cpp_on()");
connectorCb.Call(4, argv, &async);
} }
@ -397,7 +399,9 @@ private:
v8::Local<v8::Function> decor = v8::Local<v8::Function>::Cast(v8::Script::Compile(code)->Run()); v8::Local<v8::Function> decor = v8::Local<v8::Function>::Cast(v8::Script::Compile(code)->Run());
Nan::Callback decorCb(decor); Nan::Callback decorCb(decor);
v8::Local<v8::Value> argv[] = { info.This(), info[0], raw }; v8::Local<v8::Value> argv[] = { info.This(), info[0], raw };
v8::Local<v8::Function> wrap = v8::Local<v8::Function>::Cast(decorCb.Call(3, argv)); Nan::AsyncResource async("EventEmitter::js_once()");
v8::Local<v8::Value> wrapValue = decorCb.Call(3, argv, &async).ToLocalChecked();
v8::Local<v8::Function> wrap = v8::Local<v8::Function>::Cast(wrapValue);
Nan::Persistent<v8::Function> persistentWrap; Nan::Persistent<v8::Function> persistentWrap;
persistentWrap.Reset(wrap); persistentWrap.Reset(wrap);

View File

@ -26,6 +26,6 @@
"url": "https://github.com/raub/node-addon-tools.git" "url": "https://github.com/raub/node-addon-tools.git"
}, },
"dependencies": { "dependencies": {
"nan": "2.9.2" "nan": "2.10.0"
} }
} }