Cleaned-up actor examples. Added OrElse example.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@9242 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
phaller 2006-11-13 16:40:45 +00:00
parent 395d2411a3
commit 93e24c8bb8
4 changed files with 21 additions and 4 deletions

View File

@ -1,7 +1,7 @@
package examples.actors
import scala.actors.Actor._
import scala.actors.Actor
import scala.actors.Actor._
case object Stop
@ -18,7 +18,7 @@ object Links extends Application {
def top(a: Actor, n: int): Actor = actor {
Console.println("starting actor " + n + " (" + Thread.currentThread() + ")")
//self.trapExit = true
self.trapExit = true
link(a)
while (true) {
receive {

View File

@ -1,4 +1,3 @@
// Modified by Philipp Haller to use Scala's event-based actors.
package examples.actors
import scala.actors._

View File

@ -0,0 +1,19 @@
package examples.actors
import scala.actors._
import scala.actors.Actor._
object OrElse {
def main(args: Array[String]) = {
actor {
val b1 = new Channel[int]
val b2 = new Channel[int]
b2 ! 42
val item = { b1.receive {case any => any}
} orElse {
b2.receive {case any => any} }
Console.println("" + item)
}
}
}

View File

@ -16,7 +16,6 @@ object Seq extends Application {
react {
case A => scala.Console.println("2nd reactor got A")
}
()
}
}
a ! A