MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / TSFNWrap

Class TSFNWrap

test/threadsafe_function/threadsafe_function_ctx.cc:10–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace {
9
10class TSFNWrap : public ObjectWrap<TSFNWrap> {
11 public:
12 static Function Init(Napi::Env env);
13 TSFNWrap(const CallbackInfo& info);
14
15 Napi::Value GetContext(const CallbackInfo& /*info*/) {
16 Reference<Napi::Value>* ctx = _tsfn.GetContext();
17 return ctx->Value();
18 };
19
20 Napi::Value Release(const CallbackInfo& info) {
21 Napi::Env env = info.Env();
22 _deferred = std::unique_ptr<Promise::Deferred>(new Promise::Deferred(env));
23 _tsfn.Release();
24 return _deferred->Promise();
25 };
26
27 private:
28 ThreadSafeFunction _tsfn;
29 std::unique_ptr<Promise::Deferred> _deferred;
30};
31
32Function TSFNWrap::Init(Napi::Env env) {
33 Function func =

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected