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

Method terminate

lib/internal/worker.js:476–491  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

474 }
475
476 terminate() {
477 debug(`[${threadId}] terminates Worker with ID ${this.threadId}`);
478
479 this.ref();
480
481 if (this[kHandle] === null) return PromiseResolve();
482
483 this[kHandle].stopThread();
484
485 // Do not use events.once() here, because the 'exit' event will always be
486 // emitted regardless of any errors, and the point is to only resolve
487 // once the thread has actually stopped.
488 const { promise, resolve } = PromiseWithResolvers();
489 this.once('exit', resolve);
490 return promise;
491 }
492
493 async [SymbolAsyncDispose]() {
494 await this.terminate();

Callers 15

[SymbolAsyncDispose]Method · 0.95
checkTransferToWorkerFunction · 0.95
roundTripViaWorkerFunction · 0.95
testFunction · 0.95
spinWorkerFunction · 0.95
testFunction · 0.95
interruptingJSFunction · 0.95
spinWorkerFunction · 0.95
spinWorkerFunction · 0.95
RunWorkerPingTestFunction · 0.95
run_workerFunction · 0.95

Calls 3

refMethod · 0.95
debugFunction · 0.50
onceMethod · 0.45

Tested by 2

testFunction · 0.76
testFunction · 0.76