diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-07 15:27:40 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-11-07 15:59:54 +0100 |
commit | 10f3c8db6163ebe3196173c1d87e69c1fb6a3a65 (patch) | |
tree | b0043bf3feaea28eef36ed9548fa360213b1fd72 /pending/run/fallback0/fallback0-manual.scala | |
parent | 6a2b940ac6b7e511270079e1b6278c844a57f5d1 (diff) | |
download | scala-async-10f3c8db6163ebe3196173c1d87e69c1fb6a3a65.tar.gz scala-async-10f3c8db6163ebe3196173c1d87e69c1fb6a3a65.tar.bz2 scala-async-10f3c8db6163ebe3196173c1d87e69c1fb6a3a65.zip |
Minimize the public API
- Remove the CPS fallback version of async. That was not intended
to be part of 1.0.
- Lookup the await method beside the macro, rather than requiring
all calls to go to AsyncBase.await.
- Create a minimal version of Async that just contains await/async
and delegates to the macro implementation in internal._
- Add scaladoc.
Diffstat (limited to 'pending/run/fallback0/fallback0-manual.scala')
-rw-r--r-- | pending/run/fallback0/fallback0-manual.scala | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/pending/run/fallback0/fallback0-manual.scala b/pending/run/fallback0/fallback0-manual.scala deleted file mode 100644 index 9bc570d..0000000 --- a/pending/run/fallback0/fallback0-manual.scala +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com> - */ - -import language.{ reflectiveCalls, postfixOps } -import scala.concurrent.{ Future, ExecutionContext, future, Await, Promise } -import scala.concurrent.duration._ -import scala.async.EndTaskException -import scala.async.Async.{ async, await, awaitCps } -import scala.util.continuations.reset - -object TestManual extends App { - - Fallback0ManualSpec.check() - -} - -class TestFallback0ManualClass { - import ExecutionContext.Implicits.global - - def m1(x: Int): Future[Int] = future { - x + 2 - } - - def m2(y: Int): Future[Int] = { - val p = Promise[Int]() - future { reset { - val f = m1(y) - var z = 0 - val res = awaitCps(f, p) + 5 - if (res > 0) { - z = 2 - } else { - z = 4 - } - z - } } - p.future - } - - /* that isn't even supported by current CPS plugin - def m3(y: Int): Future[Int] = { - val p = Promise[Int]() - future { reset { - val f = m1(y) - var z = 0 - val res: Option[Int] = Some(5) - res match { - case None => z = 4 - case Some(a) => z = awaitCps(f, p) - 10 - } - z - } } - p.future - } - */ -} - - -object Fallback0ManualSpec extends MinimalScalaTest { - - "An async method" should { - "support await in a simple if-else expression" in { - val o = new TestFallback0ManualClass - val fut = o.m2(10) - val res = Await.result(fut, 2 seconds) - res mustBe(2) - } - } - -} |