test,worker: simplify common.isMainThread
Now that `worker_threads` do not require a flag, the logic around loading `isMainThread` can be removed. PR-URL: https://github.com/nodejs/node/pull/25426 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
cf9bcdeabe
commit
9e62bb54b3
@ -46,13 +46,7 @@ const noop = () => {};
|
||||
|
||||
const hasCrypto = Boolean(process.versions.openssl);
|
||||
|
||||
const isMainThread = (() => {
|
||||
if (require('module').builtinModules.includes('worker_threads')) {
|
||||
return require('worker_threads').isMainThread;
|
||||
}
|
||||
// Worker module not enabled → only a single main thread exists.
|
||||
return true;
|
||||
})();
|
||||
const { isMainThread } = require('worker_threads');
|
||||
|
||||
// Check for flags. Skip this for workers (both, the `cluster` module and
|
||||
// `worker_threads`) and child processes.
|
||||
|
Loading…
x
Reference in New Issue
Block a user