Skip to content

Commit

Permalink
Use default value instead of logic for default number of threads
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Aug 2, 2023
1 parent ac8eafb commit ed48a4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions subpackages/runner/source/unit_threaded/runner/options.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module unit_threaded.runner.options;

///
struct Options {
uint numThreads;
size_t numThreads;
string[] testsToRun;
bool debugOutput;
bool list;
Expand All @@ -27,9 +27,10 @@ auto getOptions(string[] args) {
import std.stdio: writeln;
import std.random: unpredictableSeed;
import std.getopt: getopt, defaultGetoptPrinter;
import std.parallelism: totalCPUs;

bool single;
uint numThreads;
size_t numThreads = totalCPUs - 1;
bool debugOutput;
bool help;
bool list;
Expand Down
7 changes: 2 additions & 5 deletions subpackages/runner/source/unit_threaded/runner/testsuite.d
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,9 @@ private:

_stopWatch.start();

const numThreads = _options.numThreads;
if (numThreads != 1) {
if (_options.numThreads != 1) {
// use a dedicated task pool with non-daemon worker threads
auto taskPool = numThreads == 0
? new TaskPool() // use all logical CPU cores
: new TaskPool(numThreads - 1); // main thread is used too
auto taskPool = new TaskPool(_options.numThreads);
_failures = reduce!((a, b) => a ~ b)(_failures, taskPool.amap!runTest(tests));
taskPool.finish(/*blocking=*/false);
} else {
Expand Down

0 comments on commit ed48a4f

Please sign in to comment.