mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 09:08:46 +00:00

Implement multi-threading support for most of the API. Thanks to Stephen Belanger for reviewing this change in its original form, to Olivia Hugger for reviewing the documentation and some of the tests coming along with it, and to Alexey Orlenko and Timothy Gu for reviewing other parts of the tests. Refs: https://github.com/ayojs/ayo/pull/110 Refs: https://github.com/ayojs/ayo/pull/114 Refs: https://github.com/ayojs/ayo/pull/117 PR-URL: https://github.com/nodejs/node/pull/20876 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
28 lines
645 B
JavaScript
28 lines
645 B
JavaScript
'use strict';
|
|
|
|
// TODO(addaleax): Figure out how to integrate the inspector with workers.
|
|
const hasInspector = process.config.variables.v8_enable_inspector === 1 &&
|
|
require('internal/worker').isMainThread;
|
|
const inspector = hasInspector ? require('inspector') : undefined;
|
|
|
|
let session;
|
|
|
|
function sendInspectorCommand(cb, onError) {
|
|
if (!hasInspector) return onError();
|
|
if (session === undefined) session = new inspector.Session();
|
|
try {
|
|
session.connect();
|
|
try {
|
|
return cb(session);
|
|
} finally {
|
|
session.disconnect();
|
|
}
|
|
} catch (e) {
|
|
return onError();
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
sendInspectorCommand
|
|
};
|