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

Function test

test/parallel/test-worker-messaging.js:80–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78}, 0));
79
80async function test() {
81 if (level < MAX_LEVEL) {
82 await createChildren();
83 await createChildren();
84 }
85
86 channel.onmessage = function(message) {
87 switch (message.data) {
88 case 'start':
89 ping();
90 break;
91 case 'end':
92 if (level === 0) {
93 completed.dec();
94 }
95 break;
96 case 'exit':
97 channel.close();
98 break;
99 }
100 };
101
102 if (level > 0) {
103 const currentThread = threadId - mainThread;
104 assert.strictEqual(level, (currentThread === 1 || currentThread === 4) ? 1 : 2);
105 parentPort.postMessage({ type: 'ready', threadId });
106 } else {
107 channel.postMessage('start');
108 ping();
109 }
110}
111
112test();

Callers 1

Calls 5

decMethod · 0.80
createChildrenFunction · 0.70
pingFunction · 0.70
closeMethod · 0.65
postMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…