MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / TSFNWrap

Method TSFNWrap

test/threadsafe_function/threadsafe_function_ctx.cc:41–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41TSFNWrap::TSFNWrap(const CallbackInfo& info) : ObjectWrap<TSFNWrap>(info) {
42 Napi::Env env = info.Env();
43
44 Reference<Napi::Value>* _ctx = new Reference<Napi::Value>;
45 *_ctx = Persistent(info[0]);
46
47 _tsfn = ThreadSafeFunction::New(
48 info.Env(),
49 Function::New(env, [](const CallbackInfo& /*info*/) {}),
50 Object::New(env),
51 "Test",
52 1,
53 1,
54 _ctx,
55 [this](Napi::Env env, Reference<Napi::Value>* ctx) {
56 _deferred->Resolve(env.Undefined());
57 ctx->Reset();
58 delete ctx;
59 });
60}
61struct SimpleTestContext {
62 SimpleTestContext(int val) : _val(val) {}
63 int _val = -1;

Callers

nothing calls this directly

Calls 4

PersistentFunction · 0.85
EnvMethod · 0.80
ResolveMethod · 0.80
ResetMethod · 0.80

Tested by

no test coverage detected