aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scala/async/internal/FutureSystem.scala
diff options
context:
space:
mode:
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 1b1ffc3..6fccfdd 100644
--- a/src/main/scala/scala/async/internal/FutureSystem.scala
+++ b/src/main/scala/scala/async/internal/FutureSystem.scala
@@ -47,6 +47,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]
@@ -100,6 +106,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)
c.Expr[Unit](Literal(Constant(()))).splice