diff --git a/build.sbt b/build.sbt index 3aa17fce..27bf0df0 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,12 @@ resolvers in ThisBuild += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-integration/" -crossScalaVersions in ThisBuild := Seq("2.13.0-pre-e2a2cba") // March 16, 2017 +crossScalaVersions in ThisBuild := Seq("2.13.0-pre-f9a019c") // April 2, 2017 scalaVersion in ThisBuild := crossScalaVersions.value.head -version in ThisBuild := "0.1.1-SNAPSHOT" +version in ThisBuild := "0.1.2-SNAPSHOT" -scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature") +scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature", "-Xfatal-warnings") cancelable in Global := true diff --git a/core/src/main/scala/scala/collection/generic/ParFactory.scala b/core/src/main/scala/scala/collection/generic/ParFactory.scala index 70bdf73e..9ee9dd42 100644 --- a/core/src/main/scala/scala/collection/generic/ParFactory.scala +++ b/core/src/main/scala/scala/collection/generic/ParFactory.scala @@ -17,6 +17,8 @@ import scala.language.higherKinds * thereof. This class extends `TraversableFactory` and provides a set of * operations to create `$Coll` objects. * + * @define factoryInfo + * This object provides a set of operations needed to create `$Coll` values. * @define coll parallel collection * @define Coll `ParIterable` * @since 2.8 diff --git a/core/src/main/scala/scala/collection/generic/ParMapFactory.scala b/core/src/main/scala/scala/collection/generic/ParMapFactory.scala index 75b9fca9..ff077c4a 100644 --- a/core/src/main/scala/scala/collection/generic/ParMapFactory.scala +++ b/core/src/main/scala/scala/collection/generic/ParMapFactory.scala @@ -22,6 +22,8 @@ import scala.language.higherKinds * * @define coll parallel map * @define Coll `ParMap` + * @define factoryInfo + * This object provides a set of operations needed to create `$Coll` values. * @author Aleksandar Prokopec * @since 2.8 */ diff --git a/core/src/main/scala/scala/collection/generic/ParSetFactory.scala b/core/src/main/scala/scala/collection/generic/ParSetFactory.scala index d9750bad..ea0dac4d 100644 --- a/core/src/main/scala/scala/collection/generic/ParSetFactory.scala +++ b/core/src/main/scala/scala/collection/generic/ParSetFactory.scala @@ -16,6 +16,8 @@ import scala.collection.parallel.ParSetLike import scala.language.higherKinds /** + * @define factoryInfo + * This object provides a set of operations needed to create `$Coll` values. * @author Aleksandar Prokopec * @since 2.8 */ diff --git a/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala b/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala index f33a8e65..b1f1eb92 100644 --- a/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala +++ b/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala @@ -39,6 +39,10 @@ import scala.collection.parallel.ParallelCollectionImplicits._ * @tparam T the element type of the collection * @tparam Repr the type of the actual collection containing the elements * + * @define undefinedorder + * The order in which operations are performed on elements is unspecified + * and may be nondeterministic. + * * @define paralleliterableinfo * This is a base trait for Scala parallel collections. It defines behaviour * common to all parallel collections. Concrete parallel collections should @@ -521,7 +525,7 @@ self: ParIterableLike[T, Repr, Sequential] => * @param p a predicate used to test elements * @return true if `p` holds for all elements, false otherwise */ - def forall(@deprecatedName('pred) p: T => Boolean): Boolean = { + def forall(p: T => Boolean): Boolean = { tasksupport.executeAndWaitResult(new Forall(p, splitter assign new DefaultSignalling with VolatileAbort)) } @@ -532,7 +536,7 @@ self: ParIterableLike[T, Repr, Sequential] => * @param p a predicate used to test elements * @return true if `p` holds for some element, false otherwise */ - def exists(@deprecatedName('pred) p: T => Boolean): Boolean = { + def exists(p: T => Boolean): Boolean = { tasksupport.executeAndWaitResult(new Exists(p, splitter assign new DefaultSignalling with VolatileAbort)) } @@ -547,7 +551,7 @@ self: ParIterableLike[T, Repr, Sequential] => * @param p predicate used to test the elements * @return an option value with the element if such an element exists, or `None` otherwise */ - def find(@deprecatedName('pred) p: T => Boolean): Option[T] = { + def find(p: T => Boolean): Option[T] = { tasksupport.executeAndWaitResult(new Find(p, splitter assign new DefaultSignalling with VolatileAbort)) } @@ -714,7 +718,7 @@ self: ParIterableLike[T, Repr, Sequential] => * @tparam That type of the resulting collection * @param z neutral element for the operator `op` * @param op the associative operator for the scan - * @param bf $bfinfo + * @param bf $pbfinfo * @return a collection containing the prefix scan of the elements in the original collection * * @usecase def scan(z: T)(op: (T, T) => T): $Coll[T] @@ -842,9 +846,6 @@ self: ParIterableLike[T, Repr, Sequential] => tasksupport.executeAndWaitResult(new ToParMap(combinerFactory(cbf), splitter)(ev) mapResult { _.resultWithTaskSupport }) } - @deprecated("use .seq.view instead", "2.11.0") - def view = seq.view - override def toArray[U >: T: ClassTag]: Array[U] = { val arr = new Array[U](size) copyToArray(arr) diff --git a/core/src/main/scala/scala/collection/parallel/ParSeqLike.scala b/core/src/main/scala/scala/collection/parallel/ParSeqLike.scala index eceb8053..3b460549 100644 --- a/core/src/main/scala/scala/collection/parallel/ParSeqLike.scala +++ b/core/src/main/scala/scala/collection/parallel/ParSeqLike.scala @@ -35,6 +35,11 @@ import scala.collection.parallel.ParallelCollectionImplicits._ * nondeterministic. If the higher-order functions given to them produce no sideeffects, * then this won't be noticeable. * + * @define mayNotTerminateInf + * Note: may not terminate for infinite-sized collections. + * @define willNotTerminateInf + * Note: will not terminate for infinite-sized collections. + * * This trait defines a new, more general `split` operation and reimplements the `split` * operation of `ParallelIterable` trait using the new `split` operation. * @@ -323,9 +328,6 @@ self => override def toSeq = this.asInstanceOf[ParSeq[T]] - @deprecated("use .seq.view", "2.11.0") - override def view = seq.view - /* tasks */ protected[this] def down(p: IterableSplitter[_]) = p.asInstanceOf[SeqSplitter[T]] diff --git a/core/src/main/scala/scala/collection/parallel/TaskSupport.scala b/core/src/main/scala/scala/collection/parallel/TaskSupport.scala index d9eec922..c479e638 100644 --- a/core/src/main/scala/scala/collection/parallel/TaskSupport.scala +++ b/core/src/main/scala/scala/collection/parallel/TaskSupport.scala @@ -56,14 +56,6 @@ trait TaskSupport extends Tasks class ForkJoinTaskSupport(val environment: ForkJoinPool = ForkJoinTasks.defaultForkJoinPool) extends TaskSupport with AdaptiveWorkStealingForkJoinTasks -/** A task support that uses a thread pool executor to schedule tasks. - * - * @see [[scala.collection.parallel.TaskSupport]] for more information. - */ -@deprecated("use `ForkJoinTaskSupport` instead", "2.11.0") -class ThreadPoolTaskSupport(val environment: ThreadPoolExecutor = ThreadPoolTasks.defaultThreadPool) -extends TaskSupport with AdaptiveWorkStealingThreadPoolTasks - /** A task support that uses an execution context to schedule tasks. * * It can be used with the default execution context implementation in the diff --git a/core/src/main/scala/scala/collection/parallel/Tasks.scala b/core/src/main/scala/scala/collection/parallel/Tasks.scala index fa5d4c14..7c1e9f99 100644 --- a/core/src/main/scala/scala/collection/parallel/Tasks.scala +++ b/core/src/main/scala/scala/collection/parallel/Tasks.scala @@ -206,142 +206,6 @@ trait AdaptiveWorkStealingTasks extends Tasks { } - -/** An implementation of tasks objects based on the Java thread pooling API. */ -@deprecated("use `ForkJoinTasks` instead", "2.11.0") -trait ThreadPoolTasks extends Tasks { - import java.util.concurrent._ - - trait WrappedTask[R, +Tp] extends Runnable with super.WrappedTask[R, Tp] { - // initially, this is null - // once the task is started, this future is set and used for `sync` - // utb: var future: Future[_] = null - @volatile var owned = false - @volatile var completed = false - - def start() = synchronized { - // debuglog("Starting " + body) - // utb: future = executor.submit(this) - executor.synchronized { - incrTasks() - executor.submit(this) - } - } - def sync() = synchronized { - // debuglog("Syncing on " + body) - // utb: future.get() - executor.synchronized { - val coresize = executor.getCorePoolSize - if (coresize < totaltasks) { - executor.setCorePoolSize(coresize + 1) - //assert(executor.getCorePoolSize == (coresize + 1)) - } - } - while (!completed) this.wait - } - def tryCancel() = synchronized { - // utb: future.cancel(false) - if (!owned) { - // debuglog("Cancelling " + body) - owned = true - true - } else false - } - def run() = { - // utb: compute - var isOkToRun = false - synchronized { - if (!owned) { - owned = true - isOkToRun = true - } - } - if (isOkToRun) { - // debuglog("Running body of " + body) - compute() - } else { - // just skip - // debuglog("skipping body of " + body) - } - } - override def release() = synchronized { - //println("releasing: " + this + ", body: " + this.body) - completed = true - executor.synchronized { - decrTasks() - } - this.notifyAll - } - } - - protected def newWrappedTask[R, Tp](b: Task[R, Tp]): WrappedTask[R, Tp] - - val environment: ThreadPoolExecutor - def executor = environment.asInstanceOf[ThreadPoolExecutor] - def queue = executor.getQueue.asInstanceOf[LinkedBlockingQueue[Runnable]] - @volatile var totaltasks = 0 - - private def incrTasks() = synchronized { - totaltasks += 1 - } - - private def decrTasks() = synchronized { - totaltasks -= 1 - } - - def execute[R, Tp](task: Task[R, Tp]): () => R = { - val t = newWrappedTask(task) - - // debuglog("-----------> Executing without wait: " + task) - t.start() - - () => { - t.sync() - t.body.forwardThrowable() - t.body.result - } - } - - def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R = { - val t = newWrappedTask(task) - - // debuglog("-----------> Executing with wait: " + task) - t.start() - - t.sync() - t.body.forwardThrowable() - t.body.result - } - - def parallelismLevel = ThreadPoolTasks.numCores - -} - -@deprecated("use `ForkJoinTasks` instead", "2.11.0") -object ThreadPoolTasks { - import java.util.concurrent._ - - val numCores = Runtime.getRuntime.availableProcessors - - val tcount = new atomic.AtomicLong(0L) - - val defaultThreadPool = new ThreadPoolExecutor( - numCores, - Int.MaxValue, - 60L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue[Runnable], - new ThreadFactory { - def newThread(r: Runnable) = { - val t = new Thread(r) - t.setName("pc-thread-" + tcount.incrementAndGet) - t.setDaemon(true) - t - } - }, - new ThreadPoolExecutor.CallerRunsPolicy - ) -} - object FutureThreadPoolTasks { import java.util.concurrent._ @@ -445,17 +309,6 @@ trait AdaptiveWorkStealingForkJoinTasks extends ForkJoinTasks with AdaptiveWorkS def newWrappedTask[R, Tp](b: Task[R, Tp]) = new WrappedTask[R, Tp](b) } -@deprecated("use `AdaptiveWorkStealingForkJoinTasks` instead", "2.11.0") -trait AdaptiveWorkStealingThreadPoolTasks extends ThreadPoolTasks with AdaptiveWorkStealingTasks { - - class WrappedTask[R, Tp](val body: Task[R, Tp]) - extends super[ThreadPoolTasks].WrappedTask[R, Tp] with super[AdaptiveWorkStealingTasks].WrappedTask[R, Tp] { - def split = body.split.map(b => newWrappedTask(b)) - } - - def newWrappedTask[R, Tp](b: Task[R, Tp]) = new WrappedTask[R, Tp](b) -} - /** An implementation of the `Tasks` that uses Scala `Future`s to compute * the work encapsulated in each task. */ diff --git a/core/src/main/scala/scala/collection/parallel/package.scala b/core/src/main/scala/scala/collection/parallel/package.scala index 1c15b9ad..93d91fee 100644 --- a/core/src/main/scala/scala/collection/parallel/package.scala +++ b/core/src/main/scala/scala/collection/parallel/package.scala @@ -81,14 +81,6 @@ package parallel { def otherwise(notbody: => R) = if (isParallel) isbody(asParSeq) else notbody } } - implicit def throwable2ops(self: Throwable) = new ThrowableOps { - def alongWith(that: Throwable) = (self, that) match { - case (self: CompositeThrowable, that: CompositeThrowable) => new CompositeThrowable(self.throwables ++ that.throwables) - case (self: CompositeThrowable, _) => new CompositeThrowable(self.throwables + that) - case (_, that: CompositeThrowable) => new CompositeThrowable(that.throwables + self) - case _ => new CompositeThrowable(Set(self, that)) - } - } } trait FactoryOps[From, Elem, To] { @@ -114,12 +106,6 @@ package parallel { def ifParSeq[R](isbody: ParSeq[T] => R): Otherwise[R] } - @deprecated("this trait will be removed", "2.11.0") - trait ThrowableOps { - @deprecated("this method will be removed", "2.11.0") - def alongWith(that: Throwable): Throwable - } - /* classes */ trait CombinerFactory[U, Repr] { @@ -134,14 +120,6 @@ package parallel { def doesShareCombiners: Boolean } - /** Composite throwable - thrown when multiple exceptions are thrown at the same time. */ - @deprecated("this class will be removed.", "2.11.0") - final case class CompositeThrowable(throwables: Set[Throwable]) extends Exception( - "Multiple exceptions thrown during a parallel computation: " + - throwables.map(t => t + "\n" + t.getStackTrace.take(10).++("...").mkString("\n")).mkString("\n\n") - ) - - /** A helper iterator for iterating very small array buffers. * Automatically forwards the signal delegate when splitting. */ diff --git a/junit/src/test/scala/scala/collection/NewBuilderTest.scala b/junit/src/test/scala/scala/collection/NewBuilderTest.scala index a60a9055..cb1faf55 100644 --- a/junit/src/test/scala/scala/collection/NewBuilderTest.scala +++ b/junit/src/test/scala/scala/collection/NewBuilderTest.scala @@ -11,7 +11,6 @@ import scala.reflect.ClassTag import org.junit.Assert._ /* Tests various maps by making sure they all agree on the same answers. */ -@deprecated("Suppress warnings", since="2.11") @RunWith(classOf[JUnit4]) class NewBuilderTest { @@ -46,14 +45,8 @@ class NewBuilderTest { test[scm.MutableList[_] ]((scm.MutableList(1): sc.Seq[Int] ).map(x => x)) test[scm.Queue[_] ]((scm.Queue(1): sc.GenTraversable[Int]).map(x => x)) test[scm.Queue[_] ]((scm.Queue(1): sc.Seq[Int] ).map(x => x)) - test[scm.DoubleLinkedList[_]]((scm.DoubleLinkedList(1): sc.GenTraversable[Int]).map(x => x)) - test[scm.DoubleLinkedList[_]]((scm.DoubleLinkedList(1): sc.Seq[Int] ).map(x => x)) - test[scm.LinkedList[_] ]((scm.LinkedList(1): sc.GenTraversable[Int]).map(x => x)) - test[scm.LinkedList[_] ]((scm.LinkedList(1): sc.Seq[Int] ).map(x => x)) test[scm.ArrayStack[_] ]((scm.ArrayStack(1): sc.GenTraversable[Int]).map(x => x)) test[scm.ArrayStack[_] ]((scm.ArrayStack(1): sc.Seq[Int] ).map(x => x)) - test[scm.Stack[_] ]((scm.Stack(1): sc.GenTraversable[Int]).map(x => x)) - test[scm.Stack[_] ]((scm.Stack(1): sc.Seq[Int] ).map(x => x)) test[scm.ArraySeq[_] ]((scm.ArraySeq(1): sc.GenTraversable[Int]).map(x => x)) test[scm.ArraySeq[_] ]((scm.ArraySeq(1): sc.Seq[Int] ).map(x => x)) @@ -84,8 +77,6 @@ class NewBuilderTest { test[sci.List[_] ]((sci.List(1): sc.Seq[Int] ).map(x => x)) test[sci.Stream[_] ]((sci.Stream(1): sc.GenTraversable[Int]).map(x => x)) test[sci.Stream[_] ]((sci.Stream(1): sc.Seq[Int] ).map(x => x)) - test[sci.Stack[_] ]((sci.Stack(1): sc.GenTraversable[Int]).map(x => x)) - test[sci.Stack[_] ]((sci.Stack(1): sc.Seq[Int] ).map(x => x)) test[sci.Queue[_] ]((sci.Queue(1): sc.GenTraversable[Int]).map(x => x)) test[sci.Queue[_] ]((sci.Queue(1): sc.Seq[Int] ).map(x => x)) test[sci.IndexedSeq[_] ]((sci.IndexedSeq(1): sc.GenTraversable[Int]).map(x => x))