aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scala/async/internal/FutureSystem.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-12-18 13:57:26 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-12-18 13:57:26 +1000
commit41ae70758a8c5b841a8b63445f82bd056a0a964f (patch)
tree19413879ab94f946c0456e97a660fb86f179a5a8 /src/main/scala/scala/async/internal/FutureSystem.scala
parent61b4c183fa2392522051305ec12ab5f433cc09a7 (diff)
parent063492a14a004cb519f553a6cd30f8b3e41f0453 (diff)
downloadscala-async-41ae70758a8c5b841a8b63445f82bd056a0a964f.tar.gz
scala-async-41ae70758a8c5b841a8b63445f82bd056a0a964f.tar.bz2
scala-async-41ae70758a8c5b841a8b63445f82bd056a0a964f.zip
Merge pull request #98 from retronym/ticket/73
Make `f(await(completedFuture))` execute `f` synchronously
Diffstat (limited to 'src/main/scala/scala/async/internal/FutureSystem.scala')
-rw-r--r--src/main/scala/scala/async/internal/FutureSystem.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/scala/scala/async/internal/FutureSystem.scala b/src/main/scala/scala/async/internal/FutureSystem.scala
index 46c0bcf..96356ed 100644
--- a/src/main/scala/scala/async/internal/FutureSystem.scala
+++ b/src/main/scala/scala/async/internal/FutureSystem.scala
@@ -49,6 +49,12 @@ trait FutureSystem {
def onComplete[A, U](future: Expr[Fut[A]], fun: Expr[Tryy[A] => U],
execContext: Expr[ExecContext]): Expr[Unit]
+ def continueCompletedFutureOnSameThread = false
+ def isCompleted(future: Expr[Fut[_]]): Expr[Boolean] =
+ throw new UnsupportedOperationException("isCompleted not supported by this FutureSystem")
+ def getCompleted[A: WeakTypeTag](future: Expr[Fut[A]]): Expr[Tryy[A]] =
+ throw new UnsupportedOperationException("getCompleted not supported by this FutureSystem")
+
/** Complete a promise with a value */
def completeProm[A](prom: Expr[Prom[A]], value: Expr[Tryy[A]]): Expr[Unit]
@@ -103,6 +109,15 @@ object ScalaConcurrentFutureSystem extends FutureSystem {
future.splice.onComplete(fun.splice)(execContext.splice)
}
+ override def continueCompletedFutureOnSameThread: Boolean = true
+
+ override def isCompleted(future: Expr[Fut[_]]): Expr[Boolean] = reify {
+ future.splice.isCompleted
+ }
+ override def getCompleted[A: WeakTypeTag](future: Expr[Fut[A]]): Expr[Tryy[A]] = reify {
+ future.splice.value.get
+ }
+
def completeProm[A](prom: Expr[Prom[A]], value: Expr[scala.util.Try[A]]): Expr[Unit] = reify {
prom.splice.complete(value.splice)
Expr[Unit](Literal(Constant(()))).splice