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:
Rich Trott 2019-01-09 15:36:24 -08:00
parent cf9bcdeabe
commit 9e62bb54b3

View File

@ -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.