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/ParallelHashTrieCheck.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala') diff --git a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala index bbec52dc92..9e29be5429 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala @@ -24,6 +24,8 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K def hasStrictOrder = false + def tasksupport: TaskSupport + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { var hm = new immutable.HashMap[K, V] val gen = vals(rnd.nextInt(vals.size)) @@ -33,6 +35,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K def fromTraversable(t: Traversable[(K, V)]) = { var phm = new ParHashMap[K, V] + phm.tasksupport = tasksupport var i = 0 for (kv <- t.toList) { phm += kv @@ -44,7 +47,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K } -object IntIntParallelHashMapCheck extends ParallelHashMapCheck[Int, Int]("Int, Int") +class IntIntParallelHashMapCheck(val tasksupport: TaskSupport) extends ParallelHashMapCheck[Int, Int]("Int, Int") with PairOperators[Int, Int] with PairValues[Int, Int] { @@ -76,6 +79,8 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" def hasStrictOrder = false + def tasksupport: TaskSupport + def ofSize(vals: Seq[Gen[T]], sz: Int) = { var hm = new immutable.HashSet[T] val gen = vals(rnd.nextInt(vals.size)) @@ -84,13 +89,14 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } def fromTraversable(t: Traversable[T]) = { - var phm = new ParHashSet[T] + var phs = new ParHashSet[T] + phs.tasksupport = tasksupport var i = 0 for (kv <- t.toList) { - phm += kv + phs += kv i += 1 } - phm + phs } override def printDataStructureDebugInfo(ds: AnyRef) = ds match { @@ -103,7 +109,7 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } -object IntParallelHashSetCheck extends ParallelHashSetCheck[Int]("Int") +class IntParallelHashSetCheck(val tasksupport: TaskSupport) extends ParallelHashSetCheck[Int]("Int") with IntOperators with IntValues { -- cgit v1.2.3