From 344ac60c3f34cc0a1c6e6aae1479878fe63476eb Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Mon, 28 Oct 2013 11:20:23 +0100 Subject: SI-7938 - parallel collections should use default ExecutionContext Parallel collections now use `scala.concurrent.ExecutionContext` by default. The `ExecutionContextTaskSupport` is optimized to use the `ForkJoinPool` underlying the `ExecutionContext` if possible. Otherwise, a fallback `TaskSupport` that creates a reduction tree and execute an operation through `Future`s is used. --- .../parallel-collections/ParallelVectorCheck.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala') diff --git a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala index a2b6cef96d..bbebd51919 100644 --- a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala @@ -17,6 +17,8 @@ import scala.collection.parallel.ops._ import immutable.Vector import immutable.VectorBuilder +import scala.collection.parallel.TaskSupport + @@ -30,6 +32,8 @@ abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.Pa def hasStrictOrder = true + def tasksupport: TaskSupport + def ofSize(vals: Seq[Gen[T]], sz: Int) = { val vb = new immutable.VectorBuilder[T]() val gen = vals(rnd.nextInt(vals.size)) @@ -38,16 +42,18 @@ abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.Pa } def fromSeq(a: Seq[T]) = { - val pa = ParVector.newCombiner[T] - for (elem <- a.toList) pa += elem - pa.result + val pc = ParVector.newCombiner[T] + for (elem <- a.toList) pc += elem + val pv = pc.result + pv.tasksupport = tasksupport + pv } } -object IntParallelVectorCheck extends ParallelVectorCheck[Int]("Int") with IntSeqOperators with IntValues { +class IntParallelVectorCheck(val tasksupport: TaskSupport) extends ParallelVectorCheck[Int]("Int") with IntSeqOperators with IntValues { override def instances(vals: Seq[Gen[Int]]) = oneOf(super.instances(vals), sized { sz => (0 until sz).toArray.toSeq }, sized { sz => -- cgit v1.2.3