summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2013-10-28 11:20:23 +0100
committerAleksandar Prokopec <axel22@gmail.com>2013-10-29 12:15:10 +0100
commit344ac60c3f34cc0a1c6e6aae1479878fe63476eb (patch)
tree97e5de64b81b5cb76913e8773171a1ad93b43244 /test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala
parent1819af77fd4ecc66c89a84ea321aa7d6f92285ec (diff)
downloadscala-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/ParallelHashTrieCheck.scala')
-rw-r--r--test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala16
1 files changed, 11 insertions, 5 deletions
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
{