Adapted examples.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@8911 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
phaller 2006-10-10 14:18:52 +00:00
parent 55378a9683
commit 0a2b5813da
1 changed files with 0 additions and 40 deletions

View File

@ -1,40 +0,0 @@
package examples.actors
import scala.actors.Actor._
import scala.actors.Actor
import scala.actors.remote.Node
import scala.actors.remote.RemoteActor._
case object Incr
case object Value
case class Result(v: int)
object RemoteCounter extends Application {
actor {
def loop(value: int): unit = {
Console.println("Value: " + value)
receive {
case Incr => loop(value + 1)
case Value => { sender ! Result(value); loop(value) }
case other => loop(value)
}
}
alive(9010)
register('counter, self)
loop(0)
}
actor {
val c = select(Node("127.0.0.1", 9010), 'counter)
c ! Incr
c ! Incr
c ! Value
receive {
case Result(v) => {
Console.println("Received result: " + v)
sender ! Incr
}
}
}
}