From 557fe9e9d2c14f363918e89056233a981dc5ef5c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Oct 2012 15:17:05 -0400 Subject: Removing actors-migration from main repository so it can live on elsewhere. * Removes actors-migration hooks from partest * Removes actors-migration code * removes actors-migration tests * removes actors-migration distribution packaging. --- build.xml | 77 +----- project/Build.scala | 5 +- .../scala/actors/migration/ActorDSL.scala | 56 ----- .../scala/actors/migration/Pattern.scala | 27 --- .../scala/actors/migration/Props.scala | 14 -- .../scala/actors/migration/StashingActor.scala | 257 --------------------- .../scala/actors/migration/Timeout.scala | 40 ---- src/build/bnd/scala-actors-migration.bnd | 5 - src/build/maven/maven-deploy.xml | 3 - src/build/maven/scala-actors-migration-pom.xml | 66 ------ src/build/pack.xml | 5 - src/partest/scala/tools/partest/PartestTask.scala | 11 - .../scala/tools/partest/nest/AntRunner.scala | 1 - .../tools/partest/nest/ConsoleFileManager.scala | 9 - .../scala/tools/partest/nest/DirectRunner.scala | 3 +- .../scala/tools/partest/nest/FileManager.scala | 1 - .../tools/partest/nest/ReflectiveRunner.scala | 4 +- .../scala/tools/partest/nest/SBTRunner.scala | 2 - test/files/jvm/actmig-PinS.check | 19 -- test/files/jvm/actmig-PinS.scala | 116 ---------- test/files/jvm/actmig-PinS_1.check | 19 -- test/files/jvm/actmig-PinS_1.scala | 139 ----------- test/files/jvm/actmig-PinS_2.check | 19 -- test/files/jvm/actmig-PinS_2.scala | 159 ------------- test/files/jvm/actmig-PinS_3.check | 19 -- test/files/jvm/actmig-PinS_3.scala | 164 ------------- test/files/jvm/actmig-hierarchy.check | 2 - test/files/jvm/actmig-hierarchy.scala | 47 ---- test/files/jvm/actmig-hierarchy_1.check | 2 - test/files/jvm/actmig-hierarchy_1.scala | 45 ---- test/files/jvm/actmig-instantiation.check | 8 - test/files/jvm/actmig-instantiation.scala | 95 -------- test/files/jvm/actmig-loop-react.check | 16 -- test/files/jvm/actmig-loop-react.scala | 195 ---------------- test/files/jvm/actmig-public-methods.check | 6 - test/files/jvm/actmig-public-methods.scala | 73 ------ test/files/jvm/actmig-public-methods_1.check | 6 - test/files/jvm/actmig-public-methods_1.scala | 104 --------- test/files/jvm/actmig-react-receive.check | 16 -- test/files/jvm/actmig-react-receive.scala | 115 --------- test/files/jvm/actmig-react-within.check | 2 - test/files/jvm/actmig-react-within.scala | 47 ---- test/files/jvm/actmig-receive.check | 27 --- test/files/jvm/actmig-receive.scala | 119 ---------- 44 files changed, 9 insertions(+), 2156 deletions(-) delete mode 100644 src/actors-migration/scala/actors/migration/ActorDSL.scala delete mode 100644 src/actors-migration/scala/actors/migration/Pattern.scala delete mode 100644 src/actors-migration/scala/actors/migration/Props.scala delete mode 100644 src/actors-migration/scala/actors/migration/StashingActor.scala delete mode 100644 src/actors-migration/scala/actors/migration/Timeout.scala delete mode 100644 src/build/bnd/scala-actors-migration.bnd delete mode 100644 src/build/maven/scala-actors-migration-pom.xml delete mode 100644 test/files/jvm/actmig-PinS.check delete mode 100644 test/files/jvm/actmig-PinS.scala delete mode 100644 test/files/jvm/actmig-PinS_1.check delete mode 100644 test/files/jvm/actmig-PinS_1.scala delete mode 100644 test/files/jvm/actmig-PinS_2.check delete mode 100644 test/files/jvm/actmig-PinS_2.scala delete mode 100644 test/files/jvm/actmig-PinS_3.check delete mode 100644 test/files/jvm/actmig-PinS_3.scala delete mode 100644 test/files/jvm/actmig-hierarchy.check delete mode 100644 test/files/jvm/actmig-hierarchy.scala delete mode 100644 test/files/jvm/actmig-hierarchy_1.check delete mode 100644 test/files/jvm/actmig-hierarchy_1.scala delete mode 100644 test/files/jvm/actmig-instantiation.check delete mode 100644 test/files/jvm/actmig-instantiation.scala delete mode 100644 test/files/jvm/actmig-loop-react.check delete mode 100644 test/files/jvm/actmig-loop-react.scala delete mode 100644 test/files/jvm/actmig-public-methods.check delete mode 100644 test/files/jvm/actmig-public-methods.scala delete mode 100644 test/files/jvm/actmig-public-methods_1.check delete mode 100644 test/files/jvm/actmig-public-methods_1.scala delete mode 100644 test/files/jvm/actmig-react-receive.check delete mode 100644 test/files/jvm/actmig-react-receive.scala delete mode 100644 test/files/jvm/actmig-react-within.check delete mode 100644 test/files/jvm/actmig-react-within.scala delete mode 100644 test/files/jvm/actmig-receive.check delete mode 100644 test/files/jvm/actmig-receive.scala diff --git a/build.xml b/build.xml index c9027e0985..41a4488a55 100644 --- a/build.xml +++ b/build.xml @@ -1024,7 +1024,6 @@ QUICK BUILD (QUICK) - @@ -1283,33 +1282,7 @@ QUICK BUILD (QUICK) - - - - - - - - - - - - - - - - - - - - - - + @@ -1514,14 +1487,11 @@ PACKED QUICK BUILD (PACK) - + - - - - + @@ -1682,7 +1652,6 @@ PACKED QUICK BUILD (PACK) - @@ -1752,7 +1721,6 @@ OSGi Artifacts - @@ -1773,7 +1741,6 @@ OSGi Artifacts - @@ -2321,7 +2288,6 @@ DOCUMENTATION - @@ -2348,7 +2314,6 @@ DOCUMENTATION rawOutput="${scaladoc.raw.output}" noPrefixes="${scaladoc.no.prefixes}"> - @@ -2547,35 +2512,9 @@ DOCUMENTATION - - - - - - - - - - - - - - - + @@ -2592,7 +2531,6 @@ BOOTRAPING TEST AND TEST SUITE - @@ -2741,7 +2679,6 @@ DISTRIBUTION - @@ -2802,9 +2739,6 @@ DISTRIBUTION - - - @@ -2982,9 +2916,6 @@ POSITIONS - - - diff --git a/project/Build.scala b/project/Build.scala index d8468032ef..a50a572d54 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -24,9 +24,9 @@ object ScalaBuild extends Build with Layers with Packaging with Testing { ) // Collections of projects to run 'compile' on. - lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, actorsMigration, swing, forkjoin, fjbg) + lazy val compiledProjects = Seq(quickLib, quickComp, continuationsLibrary, actors, swing, forkjoin, fjbg) // Collection of projects to 'package' and 'publish' together. - lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, actors, actorsMigration, continuationsPlugin, jline, scalap) + lazy val packagedBinaryProjects = Seq(scalaLibrary, scalaCompiler, swing, actors, continuationsPlugin, jline, scalap) lazy val partestRunProjects = Seq(testsuite, continuationsTestsuite) private def epflPomExtra = ( @@ -205,7 +205,6 @@ object ScalaBuild extends Build with Layers with Packaging with Testing { lazy val dependentProjectSettings = settingOverrides ++ Seq(quickScalaInstance, quickScalaLibraryDependency, addCheaterDependency("scala-library")) lazy val actors = Project("scala-actors", file(".")) settings(dependentProjectSettings:_*) dependsOn(forkjoin % "provided") lazy val swing = Project("scala-swing", file(".")) settings(dependentProjectSettings:_*) dependsOn(actors % "provided") - lazy val actorsMigration = Project("scala-actors-migration", file(".")) settings(dependentProjectSettings:_*) dependsOn(actors % "provided") // This project will generate man pages (in man1 and html) for scala. lazy val manmakerSettings: Seq[Setting[_]] = dependentProjectSettings :+ externalDeps lazy val manmaker = Project("manual", file(".")) settings(manmakerSettings:_*) diff --git a/src/actors-migration/scala/actors/migration/ActorDSL.scala b/src/actors-migration/scala/actors/migration/ActorDSL.scala deleted file mode 100644 index b8cb8ec998..0000000000 --- a/src/actors-migration/scala/actors/migration/ActorDSL.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.actors -package migration - -import scala.actors.{ Actor, ActorRef, InternalActorRef } -import scala.collection.immutable -import scala.reflect.ClassTag - -object ActorDSL { - - private[migration] val contextStack = new ThreadLocal[immutable.Stack[Boolean]] { - override def initialValue() = immutable.Stack[Boolean]() - } - - private[this] def withCleanContext(block: => ActorRef): ActorRef = { - // push clean marker - val old = contextStack.get - contextStack.set(old.push(true)) - try { - val instance = block - - if (instance eq null) - throw new Exception("ActorRef can't be 'null'") - - instance - } finally { - val stackAfter = contextStack.get - if (stackAfter.nonEmpty) - contextStack.set(if (!stackAfter.head) stackAfter.pop.pop else stackAfter.pop) - } - } - - /** - * Create an actor from the given thunk which must produce an [[scala.actors.Actor]]. - * - * @param ctor is a by-name argument which captures an [[scala.actors.Actor]] - * factory; do not make the generated object accessible to code - * outside and do not return the same object upon subsequent invocations. - */ - def actor[T <: InternalActor: ClassTag](ctor: ⇒ T): ActorRef = { - withCleanContext { - val newActor = ctor - val newRef = new InternalActorRef(newActor) - newActor.start() - newRef - } - } - -} diff --git a/src/actors-migration/scala/actors/migration/Pattern.scala b/src/actors-migration/scala/actors/migration/Pattern.scala deleted file mode 100644 index 25ba191ce7..0000000000 --- a/src/actors-migration/scala/actors/migration/Pattern.scala +++ /dev/null @@ -1,27 +0,0 @@ -package scala.actors.migration - -import scala.actors._ -import scala.concurrent.duration.Duration -import language.implicitConversions - -object pattern { - - implicit def ask(ar: ActorRef): AskableActorRef = - new AskableActorRef(ar) -} - -/** - * ActorRef with support for ask(?) operation. - */ -class AskableActorRef(val ar: ActorRef) extends ActorRef { - - def !(message: Any)(implicit sender: ActorRef = null): Unit = ar.!(message)(sender) - - def ?(message: Any)(implicit timeout: Timeout): scala.concurrent.Future[Any] = ar.?(message, timeout.duration) - - private[actors] def ?(message: Any, timeout: Duration): scala.concurrent.Future[Any] = ar.?(message, timeout) - - def forward(message: Any) = ar.forward(message) - - private[actors] def localActor: AbstractActor = ar.localActor -} diff --git a/src/actors-migration/scala/actors/migration/Props.scala b/src/actors-migration/scala/actors/migration/Props.scala deleted file mode 100644 index 00bc9d93f8..0000000000 --- a/src/actors-migration/scala/actors/migration/Props.scala +++ /dev/null @@ -1,14 +0,0 @@ -package scala.actors.migration - -import scala.actors._ - -/** - * ActorRef configuration object. It represents the minimal subset of Akka Props class. - */ -case class Props(creator: () ⇒ InternalActor, dispatcher: String) { - - /** - * Returns a new Props with the specified creator set - */ - final def withCreator(c: ⇒ InternalActor) = copy(creator = () ⇒ c) -} diff --git a/src/actors-migration/scala/actors/migration/StashingActor.scala b/src/actors-migration/scala/actors/migration/StashingActor.scala deleted file mode 100644 index 12bad2ed1c..0000000000 --- a/src/actors-migration/scala/actors/migration/StashingActor.scala +++ /dev/null @@ -1,257 +0,0 @@ -package scala.actors.migration - -import scala.actors._ -import scala.actors.Actor._ -import scala.collection._ -import scala.concurrent.duration.Duration -import java.util.concurrent.TimeUnit -import scala.language.implicitConversions - -object StashingActor extends Combinators { - implicit def mkBody[A](body: => A) = new InternalActor.Body[A] { - def andThen[B](other: => B): Unit = Actor.rawSelf.seq(body, other) - } -} - -@deprecated("Scala Actors are being removed from the standard library. Please refer to the migration guide.", "2.10.0") -trait StashingActor extends InternalActor { - type Receive = PartialFunction[Any, Unit] - - // checks if StashingActor is created within the actorOf block - creationCheck() - - private[actors] val ref = new InternalActorRef(this) - - val self: ActorRef = ref - - protected[this] val context: ActorContext = new ActorContext(this) - - @volatile - private var myTimeout: Option[Long] = None - - private val stash = new MQueue[Any]("Stash") - - /** - * Migration notes: - * this method replaces receiveWithin, receive and react methods from Scala Actors. - */ - def receive: Receive - - /** - * User overridable callback. - *

- * Is called when an Actor is started by invoking 'actor'. - */ - def preStart() {} - - /** - * User overridable callback. - *

- * Is called when 'actor.stop()' is invoked. - */ - def postStop() {} - - /** - * User overridable callback. - *

- * Is called on a crashed Actor right BEFORE it is restarted to allow clean - * up of resources before Actor is terminated. - * By default it calls postStop() - */ - def preRestart(reason: Throwable, message: Option[Any]) { postStop() } - - /** - * Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. - * Puts the behavior on top of the hotswap stack. - * If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack - */ - private def become(behavior: Receive, discardOld: Boolean = true) { - if (discardOld) unbecome() - behaviorStack = behaviorStack.push(wrapWithSystemMessageHandling(behavior)) - } - - /** - * Reverts the Actor behavior to the previous one in the hotswap stack. - */ - private def unbecome() { - // never unbecome the initial behavior - if (behaviorStack.size > 1) - behaviorStack = behaviorStack.pop - } - - /** - * User overridable callback. - *

- * Is called when a message isn't handled by the current behavior of the actor - * by default it does: EventHandler.warning(self, message) - */ - def unhandled(message: Any) { - message match { - case Terminated(dead) ⇒ throw new DeathPactException(dead) - case _ ⇒ System.err.println("Unhandeled message " + message) - } - } - - protected def sender: ActorRef = new OutputChannelRef(internalSender) - - override def act(): Unit = internalAct() - - override def start(): StashingActor = { - super.start() - this - } - - override def receive[R](f: PartialFunction[Any, R]): R - - /* - * Internal implementation. - */ - - private[actors] var behaviorStack = immutable.Stack[PartialFunction[Any, Unit]]() - - /* - * Checks that StashingActor instances can only be created using the ActorDSL. - */ - private[this] def creationCheck(): Unit = { - // creation check (see ActorRef) - val context = ActorDSL.contextStack.get - if (context.isEmpty) - throw new RuntimeException("In order to create a StashingActor one must use the ActorDSL object") - else { - if (!context.head) - throw new RuntimeException("Cannot create more than one actor") - else - ActorDSL.contextStack.set(context.push(false)) - } - - } - - private[actors] override def preAct() { - preStart() - } - - /** - * Adds message to a stash, to be processed later. Stashed messages can be fed back into the $actor's - * mailbox using unstashAll(). - * - * Temporarily stashing away messages that the $actor does not (yet) handle simplifies implementing - * certain messaging protocols. - */ - final def stash(msg: Any): Unit = { - stash.append(msg, null) - } - - final def unstashAll(): Unit = { - mailbox.prepend(stash) - stash.clear() - } - - /** - * Wraps any partial function with Exit message handling. - */ - private[actors] def wrapWithSystemMessageHandling(pf: PartialFunction[Any, Unit]): PartialFunction[Any, Unit] = { - - def swapExitHandler(pf: PartialFunction[Any, Unit]) = new PartialFunction[Any, Unit] { - def swapExit(v: Any) = v match { - case Exit(from, reason) => - Terminated(new InternalActorRef(from.asInstanceOf[InternalActor])) - case v => v - } - - def isDefinedAt(v: Any) = pf.isDefinedAt(swapExit(v)) - def apply(v: Any) = pf(swapExit(v)) - } - - swapExitHandler(pf orElse { - case m => unhandled(m) - }) - } - - /** - * Method that models the behavior of Akka actors. - */ - private[actors] def internalAct() { - trapExit = true - behaviorStack = behaviorStack.push(wrapWithSystemMessageHandling(receive)) - loop { - if (myTimeout.isDefined) - reactWithin(myTimeout.get)(behaviorStack.top) - else - react(behaviorStack.top) - } - } - - private[actors] override def internalPostStop() = postStop() - - // Used for pattern matching statement similar to Akka - lazy val ReceiveTimeout = TIMEOUT - - /** - * Used to simulate Akka context behavior. Should be used only for migration purposes. - */ - protected[actors] class ActorContext(val actr: StashingActor) { - - /** - * Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. - * Puts the behavior on top of the hotswap stack. - * If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack - */ - def become(behavior: Receive, discardOld: Boolean = true) = actr.become(behavior, discardOld) - - /** - * Reverts the Actor behavior to the previous one in the hotswap stack. - */ - def unbecome() = actr.unbecome() - - /** - * Shuts down the actor its dispatcher and message queue. - */ - def stop(subject: ActorRef): Nothing = if (subject != ref) - throw new RuntimeException("Only stoping of self is allowed during migration.") - else - actr.exit() - - /** - * Registers this actor as a Monitor for the provided ActorRef. - * @return the provided ActorRef - */ - def watch(subject: ActorRef): ActorRef = { - actr.watch(subject) - subject - } - - /** - * Unregisters this actor as Monitor for the provided ActorRef. - * @return the provided ActorRef - */ - def unwatch(subject: ActorRef): ActorRef = { - actr unwatch subject - subject - } - - /** - * Defines the receiver timeout value. - */ - final def setReceiveTimeout(timeout: Duration): Unit = - actr.myTimeout = Some(timeout.toMillis) - - /** - * Gets the current receiveTimeout - */ - final def receiveTimeout: Option[Duration] = - actr.myTimeout.map(Duration(_, TimeUnit.MILLISECONDS)) - - } -} - -/** - * This message is thrown by default when an Actor does not handle termination. - */ -class DeathPactException(ref: ActorRef = null) extends Exception { - override def fillInStackTrace() = this //Don't waste cycles generating stack trace -} - -/** - * Message that is sent to a watching actor when the watched actor terminates. - */ -case class Terminated(actor: ActorRef) diff --git a/src/actors-migration/scala/actors/migration/Timeout.scala b/src/actors-migration/scala/actors/migration/Timeout.scala deleted file mode 100644 index 32ea5f20fc..0000000000 --- a/src/actors-migration/scala/actors/migration/Timeout.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.actors.migration - -import scala.concurrent.duration.Duration -import java.util.concurrent.TimeUnit -import scala.language.implicitConversions - -case class Timeout(duration: Duration) { - def this(timeout: Long) = this(Duration(timeout, TimeUnit.MILLISECONDS)) - def this(length: Long, unit: TimeUnit) = this(Duration(length, unit)) -} - -object Timeout { - - /** - * A timeout with zero duration, will cause most requests to always timeout. - */ - val zero = new Timeout(Duration.Zero) - - /** - * A Timeout with infinite duration. Will never timeout. Use extreme caution with this - * as it may cause memory leaks, blocked threads, or may not even be supported by - * the receiver, which would result in an exception. - */ - val never = new Timeout(Duration.Inf) - - def apply(timeout: Long) = new Timeout(timeout) - def apply(length: Long, unit: TimeUnit) = new Timeout(length, unit) - - implicit def durationToTimeout(duration: Duration) = new Timeout(duration) - implicit def intToTimeout(timeout: Int) = new Timeout(timeout) - implicit def longToTimeout(timeout: Long) = new Timeout(timeout) -} diff --git a/src/build/bnd/scala-actors-migration.bnd b/src/build/bnd/scala-actors-migration.bnd deleted file mode 100644 index 2cddfb620a..0000000000 --- a/src/build/bnd/scala-actors-migration.bnd +++ /dev/null @@ -1,5 +0,0 @@ -Bundle-Name: Scala Actors Migration -Bundle-SymbolicName: org.scala-lang.scala-actors-migration -ver: @VERSION@ -Bundle-Version: ${ver} -Export-Package: *;version=${ver} diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml index 131358f0f3..bd946bf0f3 100644 --- a/src/build/maven/maven-deploy.xml +++ b/src/build/maven/maven-deploy.xml @@ -113,7 +113,6 @@ - @@ -175,7 +174,6 @@ - @@ -244,7 +242,6 @@ - diff --git a/src/build/maven/scala-actors-migration-pom.xml b/src/build/maven/scala-actors-migration-pom.xml deleted file mode 100644 index 93fc34ece9..0000000000 --- a/src/build/maven/scala-actors-migration-pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - 4.0.0 - org.scala-lang - scala-actors-migration - jar - @VERSION@ - Scala Migration Kit - Migration kit that enables easy transition from the Scala Actors to Akka. - http://www.scala-lang.org/ - 2012 - - LAMP/EPFL - http://lamp.epfl.ch/ - - - - BSD-like - http://www.scala-lang.org/downloads/license.html - - repo - - - - scm:git:git://github.com/scala/scala.git - https://github.com/scala/scala.git - - - JIRA - https://issues.scala-lang.org/ - - - - org.scala-lang - scala-library - @VERSION@ - - - org.scala-lang - scala-actors - @VERSION@ - - - - - scala-tools.org - @RELEASE_REPOSITORY@ - - - scala-tools.org - @SNAPSHOT_REPOSITORY@ - false - - - - - lamp - EPFL LAMP - - - Typesafe - Typesafe, Inc. - - - diff --git a/src/build/pack.xml b/src/build/pack.xml index 1735b93f3f..79611b55a2 100644 --- a/src/build/pack.xml +++ b/src/build/pack.xml @@ -155,7 +155,6 @@ MAIN DISTRIBUTION PACKAGING - @@ -218,10 +217,6 @@ MAIN DISTRIBUTION PACKAGING basedir="${build-docs.dir}/continuations-plugin"> - - - new File(fs) }) find { f => - f.getName match { - case "scala-actors-migration.jar" => true - case "actors-migration" if (f.getParentFile.getName == "classes") => true - case _ => false - } - } - } getOrElse sys.error("Provided classpath does not contain a Scala actors.") - def scalacArgsFlat: Option[Seq[String]] = scalacArgs map (_ flatMap { a => val parts = a.getParts if(parts eq null) Seq[String]() else parts.toSeq @@ -362,7 +352,6 @@ class PartestTask extends Task with CompilationPathProperty { antFileManager.LATEST_COMP = scalaCompiler.getAbsolutePath antFileManager.LATEST_PARTEST = scalaPartest.getAbsolutePath antFileManager.LATEST_ACTORS = scalaActors.getAbsolutePath - antFileManager.LATEST_ACTORS_MIGRATION = scalaActorsMigration.getAbsolutePath javacmd foreach (x => antFileManager.JAVACMD = x.getAbsolutePath) javaccmd foreach (x => antFileManager.JAVAC_CMD = x.getAbsolutePath) diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala index ee644c5315..8c2d7029ba 100644 --- a/src/partest/scala/tools/partest/nest/AntRunner.scala +++ b/src/partest/scala/tools/partest/nest/AntRunner.scala @@ -24,7 +24,6 @@ class AntRunner extends DirectRunner { var LATEST_COMP: String = _ var LATEST_PARTEST: String = _ var LATEST_ACTORS: String = _ - var LATEST_ACTORS_MIGRATION: String = _ val testRootPath: String = "test" val testRootDir: Directory = Directory(testRootPath) } diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 32f14872ec..442c0e8427 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -84,7 +84,6 @@ class ConsoleFileManager extends FileManager { latestFile = testClassesDir.parent / "bin" latestLibFile = testClassesDir / "library" latestActorsFile = testClassesDir / "library" / "actors" - latestActMigFile = testClassesDir / "actors-migration" latestReflectFile = testClassesDir / "reflect" latestCompFile = testClassesDir / "compiler" latestPartestFile = testClassesDir / "partest" @@ -96,7 +95,6 @@ class ConsoleFileManager extends FileManager { latestFile = dir / "bin" latestLibFile = dir / "lib/scala-library.jar" latestActorsFile = dir / "lib/scala-actors.jar" - latestActMigFile = dir / "lib/scala-actors-migration.jar" latestReflectFile = dir / "lib/scala-reflect.jar" latestCompFile = dir / "lib/scala-compiler.jar" latestPartestFile = dir / "lib/scala-partest.jar" @@ -108,7 +106,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("build/quick/bin") latestLibFile = prefixFile("build/quick/classes/library") latestActorsFile = prefixFile("build/quick/classes/library/actors") - latestActMigFile = prefixFile("build/quick/classes/actors-migration") latestReflectFile = prefixFile("build/quick/classes/reflect") latestCompFile = prefixFile("build/quick/classes/compiler") latestPartestFile = prefixFile("build/quick/classes/partest") @@ -120,7 +117,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFileWith(p, "bin") latestLibFile = prefixFileWith(p, "lib/scala-library.jar") latestActorsFile = prefixFileWith(p, "lib/scala-actors.jar") - latestActMigFile = prefixFileWith(p, "lib/scala-actors-migration.jar") latestReflectFile = prefixFileWith(p, "lib/scala-reflect.jar") latestCompFile = prefixFileWith(p, "lib/scala-compiler.jar") latestPartestFile = prefixFileWith(p, "lib/scala-partest.jar") @@ -131,7 +127,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("dists/latest/bin") latestLibFile = prefixFile("dists/latest/lib/scala-library.jar") latestActorsFile = prefixFile("dists/latest/lib/scala-actors.jar") - latestActMigFile = prefixFile("dists/latest/lib/scala-actors-migration.jar") latestReflectFile = prefixFile("dists/latest/lib/scala-reflect.jar") latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar") latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar") @@ -142,7 +137,6 @@ class ConsoleFileManager extends FileManager { latestFile = prefixFile("build/pack/bin") latestLibFile = prefixFile("build/pack/lib/scala-library.jar") latestActorsFile = prefixFile("build/pack/lib/scala-actors.jar") - latestActMigFile = prefixFile("build/pack/lib/scala-actors-migration.jar") latestReflectFile = prefixFile("build/pack/lib/scala-reflect.jar") latestCompFile = prefixFile("build/pack/lib/scala-compiler.jar") latestPartestFile = prefixFile("build/pack/lib/scala-partest.jar") @@ -180,7 +174,6 @@ class ConsoleFileManager extends FileManager { LATEST_COMP = latestCompFile.getAbsolutePath LATEST_PARTEST = latestPartestFile.getAbsolutePath LATEST_ACTORS = latestActorsFile.getAbsolutePath - LATEST_ACTORS_MIGRATION = latestActMigFile.getAbsolutePath } var LATEST_LIB: String = "" @@ -188,12 +181,10 @@ class ConsoleFileManager extends FileManager { var LATEST_COMP: String = "" var LATEST_PARTEST: String = "" var LATEST_ACTORS: String = "" - var LATEST_ACTORS_MIGRATION: String = "" var latestFile: File = _ var latestLibFile: File = _ var latestActorsFile: File = _ - var latestActMigFile: File = _ var latestReflectFile: File = _ var latestCompFile: File = _ var latestPartestFile: File = _ diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index a890a57f14..0f926ee69e 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -49,10 +49,9 @@ trait DirectRunner { val latestLibFile = new File(fileManager.LATEST_LIB) val latestPartestFile = new File(fileManager.LATEST_PARTEST) val latestActorsFile = new File(fileManager.LATEST_ACTORS) - val latestActMigFile = new File(fileManager.LATEST_ACTORS_MIGRATION) val scalacheckURL = PathSettings.scalaCheck.toURL val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs( - scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestActMigFile, latestPartestFile).map(_.toURI.toURL)) + scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestPartestFile).map(_.toURI.toURL)) ) val kindFiles = onlyValidTestPaths(_kindFiles) diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 512c718040..b6d89177ca 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -64,7 +64,6 @@ trait FileManager extends FileUtil { var LATEST_COMP: String var LATEST_PARTEST: String var LATEST_ACTORS: String - var LATEST_ACTORS_MIGRATION: String var showDiff = false var updateCheck = false diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 838bf56d73..99043d8f95 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -48,9 +48,9 @@ class ReflectiveRunner { new ConsoleFileManager import fileManager. - { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile } + { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile } val files = - Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile) map (x => io.File(x)) + Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile) map (x => io.File(x)) val sepUrls = files map (_.toURL) var sepLoader = new URLClassLoader(sepUrls, null) diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala index 206ee19c76..b0ce6579ac 100644 --- a/src/partest/scala/tools/partest/nest/SBTRunner.scala +++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala @@ -17,7 +17,6 @@ object SBTRunner extends DirectRunner { var LATEST_COMP: String = _ var LATEST_PARTEST: String = _ var LATEST_ACTORS: String = _ - var LATEST_ACTORS_MIGRATION: String = _ val testRootPath: String = "test" val testRootDir: Directory = Directory(testRootPath) } @@ -61,7 +60,6 @@ object SBTRunner extends DirectRunner { fileManager.LATEST_COMP = findClasspath("scala-compiler", "scala-compiler") getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH) fileManager.LATEST_PARTEST = findClasspath("scala-partest", "partest") getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH) fileManager.LATEST_ACTORS = findClasspath("scala-actors", "actors") getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH) - fileManager.LATEST_ACTORS_MIGRATION = findClasspath("scala-actors-migration", "actors-migration") getOrElse sys.error("No scala-actors-migration found! Classpath = " + fileManager.CLASSPATH) // TODO - Do something useful here!!! fileManager.JAVAC_CMD = "javac" diff --git a/test/files/jvm/actmig-PinS.check b/test/files/jvm/actmig-PinS.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS.scala b/test/files/jvm/actmig-PinS.scala deleted file mode 100644 index 3f07fab12e..0000000000 --- a/test/files/jvm/actmig-PinS.scala +++ /dev/null @@ -1,116 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -import scala.actors.Actor._ - -/* PinS, Listing 32.1: A simple actor - */ -object SillyActor extends Actor { - def act() { - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor extends Actor { - def act() { - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver extends Actor { - import java.net.{InetAddress, UnknownHostException} - - def act() { - react { - case (name: String, actor: Actor) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): Actor = actor { - while (true) { - receive { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - - /* PinS, page 696 - */ - def makeIntActor(): Actor = actor { - receive { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - - actor { - self.trapExit = true - self.link(SillyActor) - SillyActor.start() - react { - case Exit(SillyActor, _) => - self.link(SeriousActor) - SeriousActor.start() - react { - case Exit(SeriousActor, _) => - val seriousPromise2 = Promise[Boolean] - // PinS, page 694 - val seriousActor2 = actor { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - self.link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } -} diff --git a/test/files/jvm/actmig-PinS_1.check b/test/files/jvm/actmig-PinS_1.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_1.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala deleted file mode 100644 index 495852e812..0000000000 --- a/test/files/jvm/actmig-PinS_1.scala +++ /dev/null @@ -1,139 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends Actor { - - def act() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends Actor { - def act() { - // used to make this test deterministic - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver extends Actor { - import java.net.{ InetAddress, UnknownHostException } - - def act() { - react { - case (name: String, actor: Actor) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor(new Actor { - def act() { - while (true) { - receive { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new Actor { - def act() { - receive { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - }) - - ActorDSL.actor(new Actor { - def act() { - trapExit = true - link(SillyActor.ref) - SillyActor.startPromise.success(true) - react { - case Exit(_: SillyActor, _) => - link(SeriousActor.ref) - SeriousActor.startPromise.success(true) - react { - case Exit(_: SeriousActor, _) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new Actor { - def act() { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } - }) -} diff --git a/test/files/jvm/actmig-PinS_2.check b/test/files/jvm/actmig-PinS_2.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_2.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala deleted file mode 100644 index 508525463f..0000000000 --- a/test/files/jvm/actmig-PinS_2.scala +++ /dev/null @@ -1,159 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends StashingActor { - def receive = { case _ => println("Nop") } - override def act() { - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver { - val ref = ActorDSL.actor(new NameResolver) -} - -class NameResolver extends StashingActor { - import java.net.{ InetAddress, UnknownHostException } - - def receive = { case _ => println("Nop") } - - override def act() { - react { - case (name: String, actor: ActorRef) => - actor ! getIp(name) - act() - case "EXIT" => - println("Name resolver exiting.") - // quit - case msg => - println("Unhandled message: " + msg) - act() - } - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor( - new StashingActor { - def receive = { case _ => println("Nop") } - - override def act() { - loop { - react { - case 'stop => - exit() - case msg => - println("received message: " + msg) - } - } - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - react { - case x: Int => // I only want Ints - println("Got an Int: " + x) - } - } - }) - - ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - trapExit = true - link(SillyActor.ref) - SillyActor.startPromise.success(true) - react { - case Exit(_: SillyActor, _) => - link(SeriousActor.ref) - SeriousActor.startPromise.success(true) - react { - case Exit(_: SeriousActor, _) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new StashingActor { - - def receive = { case _ => println("Nop") } - - override def act() { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - link(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - react { - case Exit(_, _) => - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - } - } - } - } - }) -} diff --git a/test/files/jvm/actmig-PinS_3.check b/test/files/jvm/actmig-PinS_3.check deleted file mode 100644 index bdbdf8a692..0000000000 --- a/test/files/jvm/actmig-PinS_3.check +++ /dev/null @@ -1,19 +0,0 @@ -I'm acting! -I'm acting! -I'm acting! -I'm acting! -I'm acting! -Post stop -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -To be or not to be. -That is the question. -That is the question. -That is the question. -That is the question. -That is the question. -received message: hi there -received message: 15 -Got an Int: 12 diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala deleted file mode 100644 index 6c6ec6789b..0000000000 --- a/test/files/jvm/actmig-PinS_3.scala +++ /dev/null @@ -1,164 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ -import scala.actors.migration._ -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object SillyActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SillyActor) -} - -/* PinS, Listing 32.1: A simple actor - */ -class SillyActor extends StashingActor { - def receive = { case _ => println("Why are you not dead"); context.stop(self) } - - override def preStart() { - Await.ready(SillyActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("I'm acting!") - context.stop(self) - } - - override def postStop() { - println("Post stop") - } -} - -object SeriousActor { - val startPromise = Promise[Boolean]() - val ref = ActorDSL.actor(new SeriousActor) -} - -class SeriousActor extends StashingActor { - def receive = { case _ => println("Nop") } - override def preStart() { - Await.ready(SeriousActor.startPromise.future, 5 seconds) - for (i <- 1 to 5) - println("To be or not to be.") - context.stop(self) - } -} - -/* PinS, Listing 32.3: An actor that calls react - */ -object NameResolver { - val ref = ActorDSL.actor(new NameResolver) -} - -class NameResolver extends StashingActor { - import java.net.{ InetAddress, UnknownHostException } - - def receive = { - case (name: String, actor: ActorRef) => - actor ! getIp(name) - case "EXIT" => - println("Name resolver exiting.") - context.stop(self) // quit - case msg => - println("Unhandled message: " + msg) - } - - def getIp(name: String): Option[InetAddress] = { - try { - Some(InetAddress.getByName(name)) - } catch { - case _: UnknownHostException => None - } - } - -} - -object Test extends App { - - /* PinS, Listing 32.2: An actor that calls receive - */ - def makeEchoActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { // how to handle receive - case 'stop => - context.stop(self) - case msg => - println("received message: " + msg) - } - }) - - /* PinS, page 696 - */ - def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => // I only want Ints - unstashAll() - println("Got an Int: " + x) - context.stop(self) - case _ => stash() - } - }) - - ActorDSL.actor(new StashingActor { - val silly = SillyActor.ref - - override def preStart() { - context.watch(SillyActor.ref) - SillyActor.startPromise.success(true) - } - - def receive = { - case Terminated(`silly`) => - unstashAll() - val serious = SeriousActor.ref - context.watch(SeriousActor.ref) - SeriousActor.startPromise.success(true) - context.become { - case Terminated(`serious`) => - val seriousPromise2 = Promise[Boolean]() - // PinS, page 694 - val seriousActor2 = ActorDSL.actor( - new StashingActor { - - def receive = { case _ => context.stop(self) } - - override def preStart() = { - for (i <- 1 to 5) - println("That is the question.") - seriousPromise2.success(true) - context.stop(self) - } - }) - - Await.ready(seriousPromise2.future, 5 seconds) - val echoActor = makeEchoActor() - context.watch(echoActor) - echoActor ! "hi there" - echoActor ! 15 - echoActor ! 'stop - context.become { - case Terminated(_) => - unstashAll() - val intActor = makeIntActor() - intActor ! "hello" - intActor ! math.Pi - // only the following send leads to output - intActor ! 12 - context.unbecome() - context.unbecome() - context.stop(self) - case m => - println("Stash 1 " + m) - stash(m) - } - case m => - println("Stash 2 " + m) - stash(m) - } - case m => - println("Stash 3 " + m) - stash(m) - } - }) -} diff --git a/test/files/jvm/actmig-hierarchy.check b/test/files/jvm/actmig-hierarchy.check deleted file mode 100644 index 317e9677c3..0000000000 --- a/test/files/jvm/actmig-hierarchy.check +++ /dev/null @@ -1,2 +0,0 @@ -hello -hello diff --git a/test/files/jvm/actmig-hierarchy.scala b/test/files/jvm/actmig-hierarchy.scala deleted file mode 100644 index 17a44fda7a..0000000000 --- a/test/files/jvm/actmig-hierarchy.scala +++ /dev/null @@ -1,47 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ - - -class ReactorActor extends Reactor[String] { - def act() { - var cond = true - loopWhile(cond) { - react { - case x if x == "hello1" => println("hello") - case "exit" => cond = false - } - } - } -} - -class ReplyActor extends ReplyReactor { - def act() { - var cond = true - loopWhile(cond) { - react { - case "hello" => println("hello") - case "exit" => cond = false; - } - } - } -} - - -object Test { - - def main(args: Array[String]) { - val reactorActor = new ReactorActor - val replyActor = new ReplyActor - reactorActor.start() - replyActor.start() - - reactorActor ! "hello1" - replyActor ! "hello" - - reactorActor ! "exit" - replyActor ! "exit" - } -} \ No newline at end of file diff --git a/test/files/jvm/actmig-hierarchy_1.check b/test/files/jvm/actmig-hierarchy_1.check deleted file mode 100644 index 317e9677c3..0000000000 --- a/test/files/jvm/actmig-hierarchy_1.check +++ /dev/null @@ -1,2 +0,0 @@ -hello -hello diff --git a/test/files/jvm/actmig-hierarchy_1.scala b/test/files/jvm/actmig-hierarchy_1.scala deleted file mode 100644 index 14f03c9d48..0000000000 --- a/test/files/jvm/actmig-hierarchy_1.scala +++ /dev/null @@ -1,45 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors._ - -class ReactorActor extends Actor { - def act() { - var cond = true - loopWhile(cond) { - react { - case x: String if x == "hello1" => println("hello") - case "exit" => cond = false - } - } - } -} - -class ReplyActor extends Actor { - def act() { - var cond = true - loopWhile(cond) { - react { - case "hello" => println("hello") - case "exit" => cond = false; - } - } - } -} - -object Test { - - def main(args: Array[String]) { - val reactorActor = new ReactorActor - val replyActor = new ReplyActor - reactorActor.start() - replyActor.start() - - reactorActor ! "hello1" - replyActor ! "hello" - - reactorActor ! "exit" - replyActor ! "exit" - } -} \ No newline at end of file diff --git a/test/files/jvm/actmig-instantiation.check b/test/files/jvm/actmig-instantiation.check deleted file mode 100644 index 08ef979794..0000000000 --- a/test/files/jvm/actmig-instantiation.check +++ /dev/null @@ -1,8 +0,0 @@ -OK error: java.lang.RuntimeException: In order to create a StashingActor one must use the ActorDSL object -OK error: java.lang.RuntimeException: Cannot create more than one actor -0 -100 -200 -300 -400 -500 diff --git a/test/files/jvm/actmig-instantiation.scala b/test/files/jvm/actmig-instantiation.scala deleted file mode 100644 index 2e3ffc3c30..0000000000 --- a/test/files/jvm/actmig-instantiation.scala +++ /dev/null @@ -1,95 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.migration._ -import scala.actors.Actor._ -import scala.actors._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer - -class TestStashingActor extends StashingActor { - - def receive = { case v: Int => Test.append(v); Test.latch.countDown() } - -} - -object Test { - val NUMBER_OF_TESTS = 5 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[Int](0) - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[ActorRef]() - - def append(v: Int) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - // plain scala actor - val a1 = actor { - react { case v: Int => Test.append(v); Test.latch.countDown() } - } - a1 ! 100 - - // simple instantiation - val a2 = ActorDSL.actor(new TestStashingActor) - a2 ! 200 - toStop += a2 - - // actor of with scala actor - val a3 = ActorDSL.actor(actor { - react { case v: Int => Test.append(v); Test.latch.countDown() } - }) - a3 ! 300 - - // using the manifest - val a4 = ActorDSL.actor(new TestStashingActor) - a4 ! 400 - toStop += a4 - - // deterministic part of a test - // creation without actor - try { - val a3 = new TestStashingActor - a3 ! -1 - } catch { - case e: Throwable => println("OK error: " + e) - } - - // actor double creation - try { - val a3 = ActorDSL.actor({ - new TestStashingActor - new TestStashingActor - }) - a3 ! -1 - } catch { - case e: Throwable => println("OK error: " + e) - } - - // actor nesting - try { - val a5 = ActorDSL.actor({ - val a6 = ActorDSL.actor(new TestStashingActor) - toStop += a6 - new TestStashingActor - }) - - a5 ! 500 - toStop += a5 - } catch { - case e: Throwable => println("Should not throw an exception: " + e) - } - - // output - latch.await(5, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! PoisonPill) - } -} diff --git a/test/files/jvm/actmig-loop-react.check b/test/files/jvm/actmig-loop-react.check deleted file mode 100644 index 2474cbe71b..0000000000 --- a/test/files/jvm/actmig-loop-react.check +++ /dev/null @@ -1,16 +0,0 @@ -do task -do task -do task -do task -working -scala got exception -working -akka got exception -do task 1 -do string I am a String -do task 42 -after react -do task 1 -do string I am a String -do task 42 -after react diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala deleted file mode 100644 index c9a3664526..0000000000 --- a/test/files/jvm/actmig-loop-react.scala +++ /dev/null @@ -1,195 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedLWCR, finishedTNR, finishedEH = Promise[Boolean] - val finishedLWCR1, finishedTNR1, finishedEH1 = Promise[Boolean] - - def testLoopWithConditionReact() = { - // Snippet showing composition of receives - // Loop with Condition Snippet - before - val myActor = actor { - var c = true - loopWhile(c) { - react { - case x: Int => - // do task - println("do task") - if (x == 42) { - c = false - finishedLWCR1.success(true) - } - } - } - } - - myActor.start() - myActor ! 1 - myActor ! 42 - - Await.ready(finishedLWCR1.future, 5 seconds) - - // Loop with Condition Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => - // do task - println("do task") - if (x == 42) { - finishedLWCR.success(true) - context.stop(self) - } - } - }) - myAkkaActor ! 1 - myAkkaActor ! 42 - } - - def testNestedReact() = { - // Snippet showing composition of receives - // Loop with Condition Snippet - before - val myActor = actor { - var c = true - loopWhile(c) { - react { - case x: Int => - // do task - println("do task " + x) - if (x == 42) { - c = false - } else { - react { - case y: String => - println("do string " + y) - } - } - println("after react") - finishedTNR1.success(true) - } - } - } - myActor.start() - - myActor ! 1 - myActor ! "I am a String" - myActor ! 42 - - Await.ready(finishedTNR1.future, 5 seconds) - - // Loop with Condition Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - - def receive = { - case x: Int => - // do task - println("do task " + x) - if (x == 42) { - println("after react") - finishedTNR.success(true) - context.stop(self) - } else - context.become(({ - case y: String => - println("do string " + y) - }: Receive).andThen(x => { - unstashAll() - context.unbecome() - }).orElse { case x => stash() }) - } - }) - - myAkkaActor ! 1 - myAkkaActor ! "I am a String" - myAkkaActor ! 42 - - } - - def exceptionHandling() = { - // Stashing actor with act and exception handler - val myActor = ActorDSL.actor(new StashingActor { - - def receive = { case _ => println("Dummy method.") } - override def act() = { - loop { - react { - case "fail" => - throw new Exception("failed") - case "work" => - println("working") - case "die" => - finishedEH1.success(true) - exit() - } - } - } - - override def exceptionHandler = { - case x: Exception => println("scala got exception") - } - - }) - - myActor ! "work" - myActor ! "fail" - myActor ! "die" - - Await.ready(finishedEH1.future, 5 seconds) - // Stashing actor in Akka style - val myAkkaActor = ActorDSL.actor(new StashingActor { - def receive = PFCatch({ - case "fail" => - throw new Exception("failed") - case "work" => - println("working") - case "die" => - finishedEH.success(true) - context.stop(self) - }, { case x: Exception => println("akka got exception") }) - }) - - myAkkaActor ! "work" - myAkkaActor ! "fail" - myAkkaActor ! "die" - } - - def main(args: Array[String]): Unit = { - testLoopWithConditionReact() - Await.ready(finishedLWCR.future, 5 seconds) - exceptionHandling() - Await.ready(finishedEH.future, 5 seconds) - testNestedReact() - Await.ready(finishedTNR.future, 5 seconds) - } - -} - -// As per Jim Mcbeath's blog (http://jim-mcbeath.blogspot.com/2008/07/actor-exceptions.html) -class PFCatch(f: PartialFunction[Any, Unit], - handler: PartialFunction[Exception, Unit]) - extends PartialFunction[Any, Unit] { - - def apply(x: Any) = { - try { - f(x) - } catch { - case e: Exception if handler.isDefinedAt(e) => handler(e) - } - } - - def isDefinedAt(x: Any) = f.isDefinedAt(x) -} - -object PFCatch { - def apply(f: PartialFunction[Any, Unit], - handler: PartialFunction[Exception, Unit]) = new PFCatch(f, handler) -} diff --git a/test/files/jvm/actmig-public-methods.check b/test/files/jvm/actmig-public-methods.check deleted file mode 100644 index c861c90e63..0000000000 --- a/test/files/jvm/actmig-public-methods.check +++ /dev/null @@ -1,6 +0,0 @@ -None -Some(bang qmark after 1) -bang -bang bang in the future after 0 -bang qmark after 0 -typed bang bang in the future after 0 diff --git a/test/files/jvm/actmig-public-methods.scala b/test/files/jvm/actmig-public-methods.scala deleted file mode 100644 index 8891c80668..0000000000 --- a/test/files/jvm/actmig-public-methods.scala +++ /dev/null @@ -1,73 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.collection.mutable.ArrayBuffer -import scala.actors.Actor._ -import scala.actors._ -import scala.util.continuations._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } - -object Test { - val NUMBER_OF_TESTS = 6 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[String]() - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[Actor]() - - def append(v: String) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - - val respActor = actor { - loop { - react { - case (x: String, time: Long) => - Thread.sleep(time) - reply(x + " after " + time) - case str: String => - append(str) - latch.countDown() - case _ => exit() - } - } - } - - toStop += respActor - - respActor ! ("bang") - - val res1 = respActor !? (("bang qmark", 0L)) - append(res1.toString) - latch.countDown() - - val res2 = respActor !? (5000, ("bang qmark", 1L)) - append(res2.toString) - latch.countDown() - - // this one should timeout - val res21 = respActor !? (1, ("bang qmark", 5000L)) - append(res21.toString) - latch.countDown() - - val fut1 = respActor !! (("bang bang in the future", 0L)) - append(fut1().toString()) - latch.countDown() - - val fut2 = respActor !! (("typed bang bang in the future", 0L), { case x: String => x }) - append(fut2()) - latch.countDown() - - // output - latch.await(10, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! 'stop) - } -} diff --git a/test/files/jvm/actmig-public-methods_1.check b/test/files/jvm/actmig-public-methods_1.check deleted file mode 100644 index c861c90e63..0000000000 --- a/test/files/jvm/actmig-public-methods_1.check +++ /dev/null @@ -1,6 +0,0 @@ -None -Some(bang qmark after 1) -bang -bang bang in the future after 0 -bang qmark after 0 -typed bang bang in the future after 0 diff --git a/test/files/jvm/actmig-public-methods_1.scala b/test/files/jvm/actmig-public-methods_1.scala deleted file mode 100644 index db21ab983c..0000000000 --- a/test/files/jvm/actmig-public-methods_1.scala +++ /dev/null @@ -1,104 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.collection.mutable.ArrayBuffer -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import scala.util._ -import scala.concurrent._ -import scala.concurrent.duration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.concurrent.duration._ -import scala.actors.migration.pattern._ -import scala.concurrent.ExecutionContext.Implicits.global - -object Test { - val NUMBER_OF_TESTS = 6 - - // used for sorting non-deterministic output - val buff = ArrayBuffer[String]() - val latch = new CountDownLatch(NUMBER_OF_TESTS) - val toStop = ArrayBuffer[ActorRef]() - - def append(v: String) = synchronized { - buff += v - } - - def main(args: Array[String]) = { - - val respActor = ActorDSL.actor(actor { - loop { - react { - case (x: String, time: Long) => - Thread.sleep(time) - reply(x + " after " + time) - case str: String => - append(str) - latch.countDown() - case x => - exit() - } - } - }) - - toStop += respActor - - respActor ! "bang" - - { - val msg = ("bang qmark", 0L) - val res = respActor.?(msg)(Timeout(Duration.Inf)) - append(Await.result(res, Duration.Inf).toString) - latch.countDown() - } - - { - val msg = ("bang qmark", 1L) - val res = respActor.?(msg)(Timeout(5 seconds)) - - val promise = Promise[Option[Any]]() - res.onComplete(v => promise.success(v.toOption)) - append(Await.result(promise.future, Duration.Inf).toString) - - latch.countDown() - } - - { - val msg = ("bang qmark", 5000L) - val res = respActor.?(msg)(Timeout(1 millisecond)) - val promise = Promise[Option[Any]]() - res.onComplete(v => promise.success(v.toOption)) - append(Await.result(promise.future, Duration.Inf).toString) - latch.countDown() - } - - { - val msg = ("bang bang in the future", 0L) - val fut = respActor.?(msg)(Timeout(Duration.Inf)) - append(Await.result(fut, Duration.Inf).toString) - latch.countDown() - } - - { - val handler: PartialFunction[Any, String] = { - case x: String => x - } - - val msg = ("typed bang bang in the future", 0L) - val fut = (respActor.?(msg)(Timeout(Duration.Inf))) - append((Await.result(fut.map(handler), Duration.Inf)).toString) - latch.countDown() - } - - // output - latch.await(10, TimeUnit.SECONDS) - if (latch.getCount() > 0) { - println("Error: Tasks have not finished!!!") - } - - buff.sorted.foreach(println) - toStop.foreach(_ ! PoisonPill) - } -} diff --git a/test/files/jvm/actmig-react-receive.check b/test/files/jvm/actmig-react-receive.check deleted file mode 100644 index cc2a426e68..0000000000 --- a/test/files/jvm/actmig-react-receive.check +++ /dev/null @@ -1,16 +0,0 @@ -do before -do task -do after -do before -do task -do after -do before -do task -do in between -do string -do after -do before -do task -do in between -do string -do after diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala deleted file mode 100644 index bf70ce0c46..0000000000 --- a/test/files/jvm/actmig-react-receive.scala +++ /dev/null @@ -1,115 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedRS, finishedRS1, finishedRSC, finishedRSC1 = Promise[Boolean] - def testComposition() = { - // Snippet showing composition of receives - // React Snippet - before - val myActor = actor { - // do before - println("do before") - receive { - case x: Int => - // do task - println("do task") - } - println("do in between") - receive { - case x: String => - // do string now - println("do string") - } - println("do after") - finishedRSC1.success(true) - } - myActor.start() - myActor ! 1 - myActor ! "1" - Await.ready(finishedRSC1.future, 5 seconds) - - // React Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - override def preStart() = { - println("do before") - } - - def receive = ({ - case x: Int => - // do task - println("do task") - }: Receive) andThen { v => - context.become { - case x: String => - //do string - println("do string") - context.stop(self) - } - println("do in between") - } - - override def postStop() = { - println("do after") - finishedRSC.success(true) - } - - }) - myAkkaActor ! 1 - myAkkaActor ! "1" - Await.ready(finishedRSC.future, 5 seconds) - } - - def main(args: Array[String]) = { - // React Snippet - before - val myActor = actor { - // do before - println("do before") - receive { - case x: Int => - // do task - println("do task") - } - println("do after") - finishedRS1.success(true) - } - myActor.start() - myActor ! 1 - - Await.ready(finishedRS1.future, 5 seconds) - - // React Snippet - migrated - val myAkkaActor = ActorDSL.actor(new StashingActor { - override def preStart() = { - println("do before") - } - - def receive = { - case x: Int => - // do task - println("do task") - context.stop(self) - } - - override def postStop() = { - println("do after") - finishedRS.success(true) - } - - }) - myAkkaActor ! 1 - - Await.ready(finishedRS.future, 5 seconds) - // Starting composition test - testComposition() - - } -} diff --git a/test/files/jvm/actmig-react-within.check b/test/files/jvm/actmig-react-within.check deleted file mode 100644 index 57798dbefb..0000000000 --- a/test/files/jvm/actmig-react-within.check +++ /dev/null @@ -1,2 +0,0 @@ -received -received diff --git a/test/files/jvm/actmig-react-within.scala b/test/files/jvm/actmig-react-within.scala deleted file mode 100644 index 3057398cb5..0000000000 --- a/test/files/jvm/actmig-react-within.scala +++ /dev/null @@ -1,47 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finished = Promise[Boolean] - - def testReactWithin() = { - val sActor = actor { - loop { - reactWithin(1) { - case scala.actors.TIMEOUT => - println("received") - exit() - case _ => - println("Should not occur.") - } - } - } - - val myActor = ActorDSL.actor(new StashingActor { - context.setReceiveTimeout(1 millisecond) - def receive = { - case ReceiveTimeout => - println("received") - finished.success(true) - context.stop(self) - case _ => - println("Should not occur.") - } - }) - } - - def main(args: Array[String]) = { - testReactWithin() - Await.ready(finished.future, 5 seconds) - } - -} diff --git a/test/files/jvm/actmig-receive.check b/test/files/jvm/actmig-receive.check deleted file mode 100644 index 30886140e1..0000000000 --- a/test/files/jvm/actmig-receive.check +++ /dev/null @@ -1,27 +0,0 @@ -Original -do before -receive 1 -do in between -receive 1 -do after -Transformed -do before -receive 1 -do in between -receive 1 -do after -Test Loop Receive -Original -do before body -receive 1 -do after receive -do before body -do after receive -after loop -Transformed -do before body -receive 1 -do after receive -do before body -do after receive -after loop diff --git a/test/files/jvm/actmig-receive.scala b/test/files/jvm/actmig-receive.scala deleted file mode 100644 index 308643cf41..0000000000 --- a/test/files/jvm/actmig-receive.scala +++ /dev/null @@ -1,119 +0,0 @@ -/** - * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change - * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov. - */ -import scala.actors.Actor._ -import scala.actors._ -import scala.actors.migration._ -import java.util.concurrent.{ TimeUnit, CountDownLatch } -import scala.collection.mutable.ArrayBuffer -import scala.concurrent.duration._ -import scala.concurrent.{ Promise, Await } - -object Test { - val finishedSingle, finishedSingle1, finishedLoop, finishedLoop1 = Promise[Boolean] - - def testDoubleReceive() = { - println("Original") - // Snippet that shows how to get rid of receive calls in Scala Actors. - // This snippet is used in the Actors Migration Kit. - val myActor = actor { - println("do before") - receive { - case "hello" => - println("receive 1") - } - println("do in between") - receive { - case "hello" => - println("receive 1") - } - println("do after") - finishedSingle.success(true) - } - - myActor ! "hello" - myActor ! "hello" - - Await.ready(finishedSingle.future, 5 seconds) - println("Transformed") - val myActorReact = actor { - println("do before") - react (({ - case "hello" => - println("receive 1") - }: PartialFunction[Any, Unit]).andThen { x => - println("do in between") - react (({ - case "hello" => - println("receive 1") - }: PartialFunction[Any, Unit]).andThen { x => - println("do after") - finishedSingle1.success(true) - }) - }) - } - - myActorReact ! "hello" - myActorReact ! "hello" - - Await.ready(finishedSingle1.future, 5 seconds) - } - - def testLoopReceive() = { - println("Test Loop Receive") - // Snippet that shows how to get rid of receive calls in loops. - // This snippet is used in the Actors Migration Kit. - println("Original") - val myActor = actor { - var c = true - while (c) { - println("do before body") - receive { - case "hello" => - println("receive 1") - case "exit" => - c = false - } - println("do after receive") - } - println("after loop") - finishedLoop.success(true) - } - - myActor ! "hello" - myActor ! "exit" - Await.ready(finishedLoop.future, 5 seconds) - println("Transformed") - - val myActorReact = actor { - var c = true - loopWhile(c) { - println("do before body") - react (({ - case "hello" => - println("receive 1") - case "exit" => - c = false - }: PartialFunction[Any, Unit]).andThen { x => - println("do after receive") - if (c == false) { - println("after loop") - finishedLoop1.success(true) - } - }) - } - } - - myActorReact ! "hello" - myActorReact ! "exit" - - Await.ready(finishedLoop1.future, 5 seconds) - } - - def main(args: Array[String]) = { - testDoubleReceive() - testLoopReceive() - } - -} -- cgit v1.2.3