summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-08-18 10:37:09 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-08-18 10:37:09 +1000
commitcd77e23b76af8538ed7e2c5c90e7845582dff460 (patch)
treee6194087f79ed68a4613f6395f005b6eb33deeb0
parent2f7a622e2de688f6b79bb6270020bc99445bada8 (diff)
parent898ee2a01f0c4522f8f9dc33fb175b352e0857e7 (diff)
downloadscala-cd77e23b76af8538ed7e2c5c90e7845582dff460.tar.gz
scala-cd77e23b76af8538ed7e2c5c90e7845582dff460.tar.bz2
scala-cd77e23b76af8538ed7e2c5c90e7845582dff460.zip
Merge pull request #4690 from retronym/topic/defaultpromise
Unfinalize the class DefaultPromise
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 078ad45be9..3538ac6b94 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -178,7 +178,9 @@ private[concurrent] object Promise {
* DefaultPromises, and `linkedRootOf` is currently only designed to be called
* by Future.flatMap.
*/
- final class DefaultPromise[T] extends AtomicReference[AnyRef](Nil) with Promise[T] {
+ // Left non-final to enable addition of extra fields by Java/Scala converters
+ // in scala-java8-compat.
+ class DefaultPromise[T] extends AtomicReference[AnyRef](Nil) with Promise[T] {
/** Get the root promise for this promise, compressing the link chain to that
* promise if necessary.
@@ -248,12 +250,12 @@ private[concurrent] object Promise {
@throws(classOf[TimeoutException])
@throws(classOf[InterruptedException])
- def ready(atMost: Duration)(implicit permit: CanAwait): this.type =
+ final def ready(atMost: Duration)(implicit permit: CanAwait): this.type =
if (tryAwait(atMost)) this
else throw new TimeoutException("Futures timed out after [" + atMost + "]")
@throws(classOf[Exception])
- def result(atMost: Duration)(implicit permit: CanAwait): T =
+ final def result(atMost: Duration)(implicit permit: CanAwait): T =
ready(atMost).value.get.get // ready throws TimeoutException if timeout so value.get is safe here
def value: Option[Try[T]] = value0
@@ -265,7 +267,7 @@ private[concurrent] object Promise {
case _ => None
}
- override def isCompleted: Boolean = isCompleted0
+ override final def isCompleted: Boolean = isCompleted0
@tailrec
private def isCompleted0: Boolean = get() match {
@@ -274,7 +276,7 @@ private[concurrent] object Promise {
case _ => false
}
- def tryComplete(value: Try[T]): Boolean = {
+ final def tryComplete(value: Try[T]): Boolean = {
val resolved = resolveTry(value)
tryCompleteAndGetListeners(resolved) match {
case null => false
@@ -297,7 +299,7 @@ private[concurrent] object Promise {
}
}
- def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit =
+ final def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit =
dispatchOrAddCallback(new CallbackRunnable[T](executor.prepare(), func))
/** Tries to add the callback, if already completed, it dispatches the callback to be executed.