diff options
author | Aleksandar Prokopec <axel22@gmail.com> | 2013-10-28 11:20:23 +0100 |
---|---|---|
committer | Aleksandar Prokopec <axel22@gmail.com> | 2013-10-29 12:15:10 +0100 |
commit | 344ac60c3f34cc0a1c6e6aae1479878fe63476eb (patch) | |
tree | 97e5de64b81b5cb76913e8773171a1ad93b43244 /test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala | |
parent | 1819af77fd4ecc66c89a84ea321aa7d6f92285ec (diff) | |
download | scala-344ac60c3f34cc0a1c6e6aae1479878fe63476eb.tar.gz scala-344ac60c3f34cc0a1c6e6aae1479878fe63476eb.tar.bz2 scala-344ac60c3f34cc0a1c6e6aae1479878fe63476eb.zip |
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.
Diffstat (limited to 'test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala')
-rw-r--r-- | test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala | 14 |
1 files changed, 10 insertions, 4 deletions
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 => |