MCPcopy Index your code
hub / github.com/nodejs/node / testWithJSMarshaller

Function testWithJSMarshaller

test/node-api/test_threadsafe_function/test.js:34–60  ·  view source on GitHub ↗
({
  threadStarter,
  quitAfter,
  abort,
  maxQueueSize,
  launchSecondary,
})

Source from the content-addressed store, hash-verified

32}
33
34function testWithJSMarshaller({
35 threadStarter,
36 quitAfter,
37 abort,
38 maxQueueSize,
39 launchSecondary,
40}) {
41 return new Promise((resolve) => {
42 const array = [];
43 binding[threadStarter](function testCallback(value) {
44 array.push(value);
45 if (array.length === quitAfter) {
46 setImmediate(() => {
47 binding.StopThread(() => {
48 resolve(array);
49 }, !!abort);
50 });
51 }
52 }, !!abort, !!launchSecondary, maxQueueSize);
53 if (threadStarter === 'StartThreadNonblocking') {
54 // Let's make this thread really busy for a short while to ensure that
55 // the queue fills and the thread receives a napi_queue_full.
56 const start = Date.now();
57 while (Date.now() - start < 200);
58 }
59 });
60}
61
62function testUnref(queueSize) {
63 return new Promise((resolve, reject) => {

Callers 1

test.jsFile · 0.85

Calls 4

nowMethod · 0.80
setImmediateFunction · 0.50
resolveFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…