Skip to content
Permalink
Browse files

test,worker: simplify common.isMainThread

Now that `worker_threads` do not require a flag, the logic around
loading `isMainThread` can be removed.

PR-URL: #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>
  • Loading branch information...
Trott authored and addaleax committed Jan 9, 2019
1 parent f0409be commit a29adef252623a74af6cd58ca3c4ca2ef5dbfe64
Showing with 1 addition and 7 deletions.
  1. +1 −7 test/common/index.js
@@ -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.

0 comments on commit a29adef

Please sign in to comment.
You can’t perform that action at this time.