MCPcopy Create free account
hub / github.com/nodejs/nan / weakCallback

Function weakCallback

test/cpp/weak2.cpp:15–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13static AsyncResource* async_resource;
14static Persistent<v8::Function> cb;
15void weakCallback(
16 const WeakCallbackInfo<int> &data) { // NOLINT(runtime/references)
17 HandleScope scope;
18 int *parameter = static_cast<int*>(data.GetInternalField(0));
19 v8::Local<v8::Value> val = New(*parameter);
20 async_resource->runInAsyncScope(
21 GetCurrentContext()->Global(), New(cb), 1, &val);
22 delete async_resource;
23 delete parameter;
24}
25
26v8::Local<v8::String> wrap() {
27 EscapableHandleScope scope;

Callers

nothing calls this directly

Calls 5

GetCurrentContextFunction · 0.85
GetInternalFieldMethod · 0.80
runInAsyncScopeMethod · 0.80
NewFunction · 0.50
GlobalMethod · 0.45

Tested by

no test coverage detected