Skip to content

Commit

Permalink
test,worker: simplify common.isMainThread
Browse files Browse the repository at this point in the history
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 14, 2019
1 parent f0409be commit a29adef
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a29adef

Please sign in to comment.