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

Function StopThread

test/threadsafe_function/threadsafe_function.cc:128–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128static Value StopThread(const CallbackInfo& info) {
129 tsfnInfo.jsFinalizeCallback = Napi::Persistent(info[0].As<Function>());
130 bool abort = info[1].As<Boolean>();
131 if (abort) {
132 s_tsfn.Abort();
133 } else {
134 s_tsfn.Release();
135 }
136 {
137 std::lock_guard<std::mutex> _(tsfnInfo.protect);
138 tsfnInfo.closeCalledFromJs = true;
139 tsfnInfo.signal.notify_one();
140 }
141 return Value();
142}
143
144// Join the thread and inform JS that we're done.
145static void JoinTheThreads(Env /* env */,

Callers

nothing calls this directly

Calls 4

PersistentFunction · 0.85
AbortMethod · 0.80
ValueClass · 0.50
ReleaseMethod · 0.45

Tested by

no test coverage detected