summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala13
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/generic/ParallelBenches.scala12
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala4
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala4
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachHeavy.scala2
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachLight.scala2
-rw-r--r--test/files/run/coder2/Coder2.scala2
7 files changed, 23 insertions, 16 deletions
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 2b2ebda2e2..3008f93ebd 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -383,17 +383,24 @@ self =>
executeAndWaitResult(new Aggregate(z, seqop, combop, parallelIterator))
}
- /** Applies a function `f` to all the elements of the receiver.
+ /** Applies a function `f` to all the elements of $coll.
*
* $undefinedorder
*
* @tparam U the result type of the function applied to each element, which is always discarded
- * @param f function that's applied to each element
+ * @param f function applied to each element
*/
- override def foreach[U](f: T => U): Unit = {
+ def pforeach[U](f: T => U): Unit = {
executeAndWaitResult(new Foreach(f, parallelIterator))
}
+ /** Applies a function `f` to all the elements of $coll in a sequential order.
+ *
+ * @tparam U the result type of the function applied to each element, which is always discarded
+ * @param f function applied to each element
+ */
+ override def foreach[U](f: T => U) = iterator.foreach(f)
+
override def count(p: T => Boolean): Int = {
executeAndWaitResult(new Count(p, parallelIterator))
}
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/generic/ParallelBenches.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/generic/ParallelBenches.scala
index e99c70d921..c0545aff52 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/generic/ParallelBenches.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/generic/ParallelBenches.scala
@@ -144,7 +144,7 @@ self =>
extends SeqBench with SeqViewBench {
def comparisonMap = collection.Map("seqview" -> runseqview _)
def runseq = this.seqcoll.foreach(operators.eachFun)
- def runpar = this.parcoll.foreach(operators.eachFun)
+ def runpar = this.parcoll.pforeach(operators.eachFun)
def runseqview = {
this.seqview.foreach(operators.eachFun)
}
@@ -161,7 +161,7 @@ self =>
extends SeqBench with SeqViewBench {
def comparisonMap = collection.Map("seqview" -> runseqview _)
def runseq = this.seqcoll.slice(0, size / 2).foreach(operators.eachFun)
- def runpar = this.parcoll.slice(0, size / 2).foreach(operators.eachFun)
+ def runpar = this.parcoll.slice(0, size / 2).pforeach(operators.eachFun)
def runseqview = this.seqview.slice(0, size / 2).foreach(operators.eachFun)
def companion = IterationS
}
@@ -176,7 +176,7 @@ self =>
extends SeqBench with SeqViewBench {
def comparisonMap = collection.Map("seqview" -> runseqview _)
def runseq = this.seqcoll.map(operators.mapper).foreach(operators.eachFun)
- def runpar = this.parcoll.map(operators.mapper).foreach(operators.eachFun)
+ def runpar = this.parcoll.map(operators.mapper).pforeach(operators.eachFun)
def runseqview = this.seqview.map(operators.mapper).foreach(operators.eachFun)
def companion = IterationM
}
@@ -196,7 +196,7 @@ self =>
val withapp = this.seqcoll.++(sqappended)
withapp.foreach(operators.eachFun)
}
- def runpar = this.parcoll.++(appended).foreach(operators.eachFun)
+ def runpar = this.parcoll.++(appended).pforeach(operators.eachFun)
def runseqview = this.seqview.++(appended).foreach(operators.eachFun)
def companion = IterationA
}
@@ -215,7 +215,7 @@ self =>
val withzip = this.seqcoll.zip(zipped)
withzip.foreach(operators.eachPairFun)
}
- def runpar = this.parcoll.zip(zipped).foreach(operators.eachPairFun)
+ def runpar = this.parcoll.zip(zipped).pforeach(operators.eachPairFun)
def runseqview = this.seqview.zip(zipped).foreach(operators.eachPairFun)
def companion = IterationZ
}
@@ -235,7 +235,7 @@ self =>
val withpatch = this.seqcollAsSeq.patch(size / 4, sqpatch, size / 2)
withpatch.foreach(operators.eachFun)
}
- def runpar = this.parcoll.patch(size / 4, patch, size / 2).foreach(operators.eachFun)
+ def runpar = this.parcoll.patch(size / 4, patch, size / 2).pforeach(operators.eachFun)
def runseqview = this.seqview.patch(size / 4, patch, size / 2).foreach(operators.eachFun)
def companion = IterationP
}
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala
index 96d75f480f..88640f3644 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala
@@ -91,7 +91,7 @@ trait ParHashTableSetBenches[T] extends StandardParIterableBenches[T, ParHashSet
extends IterableBench {
def comparisonMap = collection.Map()
def runseq = this.seqcoll.foreach(operators.foreachFun)
- def runpar = this.parcoll.foreach(operators.foreachFun)
+ def runpar = this.parcoll.pforeach(operators.foreachFun)
def companion = Foreach
}
@@ -115,7 +115,7 @@ object RefParHashTableSetBenches extends ParHashTableSetBenches[Dummy] {
val array = new Array[Int](size)
def comparisonMap = collection.Map()
def runseq = for (x <- this.seqcoll) array(x.in) += 1
- def runpar = for (x <- this.parcoll) array(x.in) += 1
+ def runpar = this.parcoll.pforeach { x => array(x.in) += 1 }
def companion = ForeachSet
override def onEnd {
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala
index 94c38b52b1..cf0e53e47d 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala
@@ -105,7 +105,7 @@ trait ParHashTableBenches[K, V] extends StandardParIterableBenches[(K, V), ParHa
extends IterableBench {
def comparisonMap = collection.Map()
def runseq = this.seqcoll.foreach(operators.foreachFun)
- def runpar = this.parcoll.foreach(operators.foreachFun)
+ def runpar = this.parcoll.pforeach(operators.foreachFun)
def companion = Foreach
}
@@ -131,7 +131,7 @@ object RefParHashTableBenches extends ParHashTableBenches[Dummy, Dummy] {
val array = new Array[Int](size)
def comparisonMap = collection.Map()
def runseq = for (p <- this.seqcoll) array(p._1.in) += 1
- def runpar = for (p <- this.parcoll) array(p._1.in) += 1
+ def runpar = this.parcoll.pforeach { p => array(p._1.in) += 1 }
def companion = ForeachSet
override def onEnd {
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachHeavy.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachHeavy.scala
index f151158ad9..4d7c48b0b4 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachHeavy.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachHeavy.scala
@@ -38,7 +38,7 @@ extends Resettable(sz, p, what, new Cont(_), new Array[Any](_), classOf[Cont]) {
def companion = ForeachHeavy
override def repetitionsPerRun = 250
- def runpar = pa.foreach(ForeachHeavy.fun)
+ def runpar = pa.pforeach(ForeachHeavy.fun)
def runseq = sequentialForeach(ForeachHeavy.fun, sz)
def runjsr = jsrarr.apply(ForeachHeavy.funjsr)
def comparisonMap = collection.Map("jsr" -> runjsr _)
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachLight.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachLight.scala
index 79901148ac..5ef41d8d5b 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachLight.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/ForeachLight.scala
@@ -19,7 +19,7 @@ class ForeachLight(sz: Int, p: Int, what: String)
extends Resettable(sz, p, what, new Cont(_), new Array[Any](_), classOf[Cont]) {
def companion = ForeachLight
- def runpar = pa.foreach(ForeachLight.fun)
+ def runpar = pa.pforeach(ForeachLight.fun)
def runseq = sequentialForeach(ForeachLight.fun, sz)
def runjsr = jsrarr.apply(ForeachLight.funjsr)
def comparisonMap = collection.Map("jsr" -> runjsr _)
diff --git a/test/files/run/coder2/Coder2.scala b/test/files/run/coder2/Coder2.scala
index a83044981b..7ecc5e67d1 100644
--- a/test/files/run/coder2/Coder2.scala
+++ b/test/files/run/coder2/Coder2.scala
@@ -163,7 +163,7 @@ class ParCoder(words: List[String]) {
/** Test code */
object Test {
- val code = "232843747294736262633"//837976"//"6477323986225453446"
+ val code = "2328437472947"//36262633"//837976"//"6477323986225453446"
//val code = "747294736262633"
/* */