diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-07-14 15:00:49 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-07-15 08:25:41 -0700 |
commit | fa8012d28687986902ce1255a19f9f49affb3bca (patch) | |
tree | ed79f2e76df3b7df1634dba252627260d4815a55 /src/library/scala/concurrent/forkjoin/package.scala | |
parent | eda41a253ee004318262ce1a12c4f44a45aec229 (diff) | |
download | scala-fa8012d28687986902ce1255a19f9f49affb3bca.tar.gz scala-fa8012d28687986902ce1255a19f9f49affb3bca.tar.bz2 scala-fa8012d28687986902ce1255a19f9f49affb3bca.zip |
Remove our fork of forkjoin. Java 8 bundles it.
Provide deprecated compatibility stubs for the types and static members,
which forward as follows:
```
scala.concurrent.forkjoin.ForkJoinPool => java.util.concurrent.ForkJoinPool
scala.concurrent.forkjoin.ForkJoinTask => java.util.concurrent.ForkJoinTask
scala.concurrent.forkjoin.ForkJoinWorkerThread => java.util.concurrent.ForkJoinWorkerThread
scala.concurrent.forkjoin.LinkedTransferQueue => java.util.concurrent.LinkedTransferQueue
scala.concurrent.forkjoin.RecursiveAction => java.util.concurrent.RecursiveAction
scala.concurrent.forkjoin.RecursiveTask => java.util.concurrent.RecursiveTask
scala.concurrent.forkjoin.ThreadLocalRandom => java.util.concurrent.ThreadLocalRandom
```
To prepare for Java 9, the Scala library does not itself use `sun.misc.Unsafe`.
However, for now, it provide a convenience accessor for it
via `scala.concurrent.util.Unsafe`. This (deprecated) class will
be removed as soon as the eco-system drops its use
(akka-actor, I'm looking at you).
Diffstat (limited to 'src/library/scala/concurrent/forkjoin/package.scala')
-rw-r--r-- | src/library/scala/concurrent/forkjoin/package.scala | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/library/scala/concurrent/forkjoin/package.scala b/src/library/scala/concurrent/forkjoin/package.scala new file mode 100644 index 0000000000..7f4524fccf --- /dev/null +++ b/src/library/scala/concurrent/forkjoin/package.scala @@ -0,0 +1,60 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2015, LAMP/EPFL and Typesafe, Inc. ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.concurrent +import java.util.{concurrent => juc} +import java.util.Collection + +package object forkjoin { + @deprecated("Use java.util.concurrent.ForkJoinPool directly, instead of this alias.", "2.12.0") + type ForkJoinPool = juc.ForkJoinPool + @deprecated("Use java.util.concurrent.ForkJoinPool directly, instead of this alias.", "2.12.0") + object ForkJoinPool { + type ForkJoinWorkerThreadFactory = juc.ForkJoinPool.ForkJoinWorkerThreadFactory + type ManagedBlocker = juc.ForkJoinPool.ManagedBlocker + + val defaultForkJoinWorkerThreadFactory: ForkJoinWorkerThreadFactory = juc.ForkJoinPool.defaultForkJoinWorkerThreadFactory + def managedBlock(blocker: ManagedBlocker): Unit = juc.ForkJoinPool.managedBlock(blocker) + } + + @deprecated("Use java.util.concurrent.ForkJoinTask directly, instead of this alias.", "2.12.0") + type ForkJoinTask[T] = juc.ForkJoinTask[T] + @deprecated("Use java.util.concurrent.ForkJoinTask directly, instead of this alias.", "2.12.0") + object ForkJoinTask { + def adapt(runnable: Runnable): ForkJoinTask[_] = juc.ForkJoinTask.adapt(runnable) + def adapt[T](callable: juc.Callable[_ <: T]): ForkJoinTask[T] = juc.ForkJoinTask.adapt(callable) + def adapt[T](runnable: Runnable, result: T): ForkJoinTask[T] = juc.ForkJoinTask.adapt(runnable, result) + def getPool(): ForkJoinPool = juc.ForkJoinTask.getPool + def getQueuedTaskCount(): Int = juc.ForkJoinTask.getQueuedTaskCount + def getSurplusQueuedTaskCount(): Int = juc.ForkJoinTask.getSurplusQueuedTaskCount + def helpQuiesce(): Unit = juc.ForkJoinTask.helpQuiesce + def inForkJoinPool(): Boolean = juc.ForkJoinTask.inForkJoinPool + def invokeAll[T <: ForkJoinTask[_]](tasks: Collection[T]): Collection[T] = juc.ForkJoinTask.invokeAll(tasks) + def invokeAll[T](t1: ForkJoinTask[T]): Unit = juc.ForkJoinTask.invokeAll(t1) + def invokeAll[T](tasks: ForkJoinTask[T]*): Unit = juc.ForkJoinTask.invokeAll(tasks: _*) + } + + @deprecated("Use java.util.concurrent.ForkJoinWorkerThread directly, instead of this alias.", "2.12.0") + type ForkJoinWorkerThread = juc.ForkJoinWorkerThread + @deprecated("Use java.util.concurrent.LinkedTransferQueue directly, instead of this alias.", "2.12.0") + type LinkedTransferQueue[T] = juc.LinkedTransferQueue[T] + @deprecated("Use java.util.concurrent.RecursiveAction directly, instead of this alias.", "2.12.0") + type RecursiveAction = juc.RecursiveAction + @deprecated("Use java.util.concurrent.RecursiveTask directly, instead of this alias.", "2.12.0") + type RecursiveTask[T] = juc.RecursiveTask[T] + + @deprecated("Use java.util.concurrent.ThreadLocalRandom directly, instead of this alias.", "2.12.0") + type ThreadLocalRandom = juc.ThreadLocalRandom + @deprecated("Use java.util.concurrent.ThreadLocalRandom directly, instead of this alias.", "2.12.0") + object ThreadLocalRandom { + // For source compatibility, current must declare the empty argument list. + // Having no argument list makes more sense since it doesn't have any side effects, + // but existing callers will break if they invoked it as `current()`. + def current() = juc.ThreadLocalRandom.current + } +} |