Skip to content

Minimize the public API #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ After async transform:

```scala
{
class stateMachine$7 extends StateMachine[scala.concurrent.Promise[Int], scala.concurrent.ExecutionContext] {
class stateMachine$7 extends ... {
def <init>() = {
super.<init>();
()
Expand Down
23 changes: 1 addition & 22 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,6 @@ testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s")

parallelExecution in Global := false

autoCompilerPlugins := true

scalacOptions ++= (scalaHome.value match {
case Some(sh) =>
// Use continuations plugin from the local scala instance
val continuationsJar = sh / "misc" / "scala-devel" / "plugins" / "continuations.jar"
("-Xplugin:" + continuationsJar.getAbsolutePath) :: Nil
case None =>
Nil
})

libraryDependencies ++= (scalaHome.value match {
case Some(sh) =>
Nil
case None =>
// Use continuations plugin from the published artifact.
compilerPlugin("org.scala-lang.plugins" % "continuations" % scalaVersion.value) :: Nil
})

scalacOptions += "-P:continuations:enable"

scalacOptions in compile ++= Seq("-optimize", "-deprecation", "-unchecked", "-Xlint", "-feature")

scalacOptions in Test ++= Seq("-Yrangepos")
Expand Down Expand Up @@ -133,4 +112,4 @@ packageOptions in packageSrc := Seq(Package.ManifestAttributes(
("Bundle-Name", s"${name.value} sources"),
("Bundle-Version", osgiVersion.value),
("Eclipse-SourceBundle", s"""${organization.value}.${name.value};version="${osgiVersion.value}";roots:="."""")
))
))
71 changes: 0 additions & 71 deletions pending/run/fallback0/fallback0-manual.scala

This file was deleted.

48 changes: 0 additions & 48 deletions pending/run/fallback0/fallback0.scala

This file was deleted.

55 changes: 55 additions & 0 deletions src/main/scala/scala/async/Async.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com>
*/

package scala.async

import scala.language.experimental.macros
import scala.concurrent.{Future, ExecutionContext}
import scala.reflect.internal.annotations.compileTimeOnly

/**
* Async blocks provide a direct means to work with [[scala.concurrent.Future]].
*
* For example, to use an API to that fetches as web page to fetch
* two pages and add their lengths:
*
* {{{
* import ExecutionContext.Implicits.global
* import scala.async.Async.{async, await}
*
* def fetchURL(url: URL): Future[String] = ...
*
* val sumLengths: Future[Int] = async {
* val body1 = fetchURL("http://scala-lang.org")
* val body2 = fetchURL("http://docs.scala-lang.org")
* await(body1).length + await(body2).length
* }
* }}}
*
* Note that the in the following program, the second fetch does *not* start
* until after the first. If you need to start tasks in parallel, you must do
* so before `await`-ing a result.
*
* {{{
* val sumLengths: Future[Int] = async {
* await(fetchURL("http://scala-lang.org")).length + await(fetchURL("http://docs.scala-lang.org")).length
* }
* }}}
*/
object Async {
/**
* Run the block of code `body` asynchronously. `body` may contain calls to `await` when the results of
* a `Future` are needed; this is translated into non-blocking code.
*/
def async[T](body: T)(implicit execContext: ExecutionContext): Future[T] = macro internal.ScalaConcurrentAsync.asyncImpl[T]

/**
* Non-blocking await the on result of `awaitable`. This may only be used directly within an enclosing `await` block.
*
* Internally, this will register the remainder of the code in enclosing `async` block as a callback
* in the `onComplete` handler of `awaitable`, and will *not* block a thread.
*/
@compileTimeOnly("`await` must be enclosed in an `async` block")
def await[T](awaitable: Future[T]): T = ??? // No implementation here, as calls to this are translated to `onComplete` by the macro.
}
12 changes: 0 additions & 12 deletions src/main/scala/scala/async/StateMachine.scala

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/scala/scala/async/continuations/CPSBasedAsync.scala

This file was deleted.

Loading