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/pc.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/pc.scala')
-rw-r--r-- | test/files/scalacheck/parallel-collections/pc.scala | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/test/files/scalacheck/parallel-collections/pc.scala b/test/files/scalacheck/parallel-collections/pc.scala index c588692fd2..a3c1df4054 100644 --- a/test/files/scalacheck/parallel-collections/pc.scala +++ b/test/files/scalacheck/parallel-collections/pc.scala @@ -6,35 +6,52 @@ import org.scalacheck._ import scala.collection.parallel._ -class ParCollProperties extends Properties("Parallel collections") { - /* Collections */ +// package here to be able access the package-private implementation and shutdown the pool +package scala { - // parallel arrays - include(mutable.IntParallelArrayCheck) + class ParCollProperties extends Properties("Parallel collections") { + + def includeAllTestsWith(support: TaskSupport) { + // parallel arrays with default task support + include(new mutable.IntParallelArrayCheck(support)) + + // parallel ranges + include(new immutable.ParallelRangeCheck(support)) + + // parallel immutable hash maps (tries) + include(new immutable.IntIntParallelHashMapCheck(support)) + + // parallel immutable hash sets (tries) + include(new immutable.IntParallelHashSetCheck(support)) + + // parallel mutable hash maps (tables) + include(new mutable.IntIntParallelHashMapCheck(support)) + + // parallel ctrie + include(new mutable.IntIntParallelConcurrentTrieMapCheck(support)) + + // parallel mutable hash sets (tables) + include(new mutable.IntParallelHashSetCheck(support)) + + // parallel vectors + include(new immutable.IntParallelVectorCheck(support)) + } + + includeAllTestsWith(defaultTaskSupport) + + val ec = scala.concurrent.ExecutionContext.fromExecutorService(java.util.concurrent.Executors.newFixedThreadPool(5)) + val ectasks = new collection.parallel.ExecutionContextTaskSupport(ec) + includeAllTestsWith(ectasks) - // parallel ranges - include(immutable.ParallelRangeCheck) - - // parallel immutable hash maps (tries) - include(immutable.IntIntParallelHashMapCheck) - - // parallel immutable hash sets (tries) - include(immutable.IntParallelHashSetCheck) - - // parallel mutable hash maps (tables) - include(mutable.IntIntParallelHashMapCheck) - - // parallel ctrie - include(mutable.IntIntParallelConcurrentTrieMapCheck) - - // parallel mutable hash sets (tables) - include(mutable.IntParallelHashSetCheck) + // no post test hooks in scalacheck, so cannot do: + // ec.shutdown() + + } - // parallel vectors - include(immutable.IntParallelVectorCheck) } -object Test extends ParCollProperties { + +object Test extends scala.ParCollProperties { /* def main(args: Array[String]) { val pc = new ParCollProperties |