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

Function CreateThread

test/threadsafe_function/threadsafe_function_sum.cc:182–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182static Value CreateThread(const CallbackInfo& info) {
183 TestData* testData = static_cast<TestData*>(info.Data());
184 // Counting expected calls like this only works because on the JS side this
185 // binding is called from a synchronous loop. This means the main loop has no
186 // chance to run the tsfn JS callback before we've counted how many threads
187 // the JS intends to create.
188 testData->expected_calls++;
189 ThreadSafeFunction tsfn = testData->tsfn;
190 int threadId = testData->threads.size();
191 // A copy of the ThreadSafeFunction will go to the thread entry point
192 testData->threads.push_back(std::thread(entryAcquire, tsfn, threadId));
193 return Number::New(info.Env(), threadId);
194}
195
196static Value StopThreads(const CallbackInfo& info) {
197 TestData* testData = static_cast<TestData*>(info.Data());

Callers

nothing calls this directly

Calls 2

DataMethod · 0.80
EnvMethod · 0.80

Tested by

no test coverage detected