From a574ccfcdd0178a3884df1460b409e0fb38ce991 Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Mon, 27 Jun 2016 09:55:00 -0400 Subject: [PATCH 1/3] Removed global std.range import in std.parallelism --- std/parallelism.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/std/parallelism.d b/std/parallelism.d index 683a3cf8757..89a8dfe9fee 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -86,7 +86,7 @@ import std.exception; import std.functional; import std.math; import std.meta; -import std.range; +import std.range.primitives; import std.traits; import std.typecons; @@ -1666,6 +1666,8 @@ public: } else { + import std.array : uninitializedArray; + auto buf = uninitializedArray!(MapType!(Args[0], functions)[])(len); alias args2 = args; alias Args2 = Args; @@ -1978,6 +1980,7 @@ public: { static if (isRandomAccessRange!S) { + import std.range : take; auto toMap = take(source, buf.length); scope(success) popSource(); } @@ -3611,6 +3614,7 @@ enum string parallelApplyMixinInputRange = q{ size_t makeTemp() { import std.algorithm.internal : addressOf; + import std.array : uninitializedArray; if (temp is null) { @@ -3642,6 +3646,8 @@ enum string parallelApplyMixinInputRange = q{ // Returns: The previous value of nPopped. static if (!bufferTrick) size_t makeTemp() { + import std.array : uninitializedArray; + if (temp is null) { temp = uninitializedArray!Temp(workUnitSize); @@ -3897,6 +3903,8 @@ version(unittest) // These are the tests that should be run every time Phobos is compiled. unittest { + import std.range : iota; + poolInstance = new TaskPool(2); scope(exit) poolInstance.stop(); @@ -4151,6 +4159,7 @@ unittest )); { + import std.array : join, split; import std.file : deleteme; string temp_file = deleteme ~ "-tempDelMe.txt"; From a5477385970c6ab7434be7d4d243ea454f34dd6c Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Mon, 27 Jun 2016 10:00:16 -0400 Subject: [PATCH 2/3] Removed global std.math import in std.parallelism --- std/parallelism.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/parallelism.d b/std/parallelism.d index 89a8dfe9fee..ea82118873b 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -84,7 +84,6 @@ import std.algorithm; import std.conv; import std.exception; import std.functional; -import std.math; import std.meta; import std.range.primitives; import std.traits; @@ -3903,6 +3902,7 @@ version(unittest) // These are the tests that should be run every time Phobos is compiled. unittest { + import std.math : log, approxEqual, sqrt; import std.range : iota; poolInstance = new TaskPool(2); From 67dbe304ab47127f4b4997c0a71fad0d91793ead Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Mon, 27 Jun 2016 10:07:00 -0400 Subject: [PATCH 3/3] Removed global std.exception import in std.parallelism --- std/parallelism.d | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/std/parallelism.d b/std/parallelism.d index ea82118873b..fc994f82c69 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -82,7 +82,6 @@ import core.thread; import std.algorithm; import std.conv; -import std.exception; import std.functional; import std.meta; import std.range.primitives; @@ -536,6 +535,7 @@ struct Task(alias fun, Args...) private void enforcePool() { + import std.exception : enforce; enforce(this.pool !is null, "Job not submitted yet."); } @@ -1528,6 +1528,7 @@ public: */ ParallelForeach!R parallel(R)(R range, size_t workUnitSize) { + import std.exception : enforce; enforce(workUnitSize > 0, "workUnitSize must be > 0."); alias RetType = ParallelForeach!R; return RetType(this, range, workUnitSize); @@ -1652,6 +1653,7 @@ public: is(MapType!(Args[0], functions) : ElementType!(Args[$ - 1])) ) { + import std.exception : enforce; alias buf = args[$ - 1]; alias args2 = args[0..$ - 1]; alias Args2 = Args[0..$ - 1]; @@ -1827,6 +1829,8 @@ public: map(S)(S source, size_t bufSize = 100, size_t workUnitSize = size_t.max) if (isInputRange!S) { + import std.exception : enforce; + enforce(workUnitSize == size_t.max || workUnitSize <= bufSize, "Work unit size must be smaller than buffer size."); alias fun = adjoin!(staticMap!(unaryFun, functions)); @@ -2478,6 +2482,8 @@ public: } else { + import std.exception : enforce; + static assert(args2.length == 1); alias range = args2[0]; @@ -3185,6 +3191,7 @@ public: @trusted void put(alias fun, Args...)(Task!(fun, Args)* task) if (isSafeReturn!(typeof(*task))) { + import std.exception : enforce; enforce(task !is null, "Cannot put a null Task on a TaskPool queue."); put(*task); } @@ -3902,6 +3909,7 @@ version(unittest) // These are the tests that should be run every time Phobos is compiled. unittest { + import std.exception : assertThrown; import std.math : log, approxEqual, sqrt; import std.range : iota;