diff --git a/docs/examples/computeserver.scala b/docs/examples/computeserver.scala index bd6f536df..788be284d 100644 --- a/docs/examples/computeserver.scala +++ b/docs/examples/computeserver.scala @@ -12,7 +12,7 @@ class ComputeServer(n: Int) { private val openJobs = new Channel[Job]() - private def processor(i: Int): Unit = { + private def processor(i: Int) { while (true) { val job = openJobs.read println("read a job") @@ -32,16 +32,17 @@ class ComputeServer(n: Int) { () => reply.get } - spawn(replicate(0, n) { processor }) + //spawn(replicate(0, n) { processor }) + spawn((0 until n).par foreach { processor }) } -object computeserver extends Application { +object computeserver extends App { def kill(delay: Int) = new java.util.Timer().schedule( new java.util.TimerTask { override def run() = { println("[killed]") - System.exit(0) + sys exit 0 } }, delay) // in milliseconds diff --git a/docs/examples/oneplacebuffer.scala b/docs/examples/oneplacebuffer.scala index 02b8a9cec..f7047a1c9 100644 --- a/docs/examples/oneplacebuffer.scala +++ b/docs/examples/oneplacebuffer.scala @@ -2,35 +2,39 @@ package examples object oneplacebuffer { - import scala.concurrent.{MailBox, ops} + import scala.actors.Actor._ + import scala.concurrent.ops class OnePlaceBuffer { - private val m = new MailBox() {} // An internal mailbox - private case class Empty() // Types of messages we deal with - private case class Full(x: Int) + private case class Put(x: Int) + private case object Get - m send Empty() // Initialization - - def write(x: Int) { - m receive { - case Empty() => - println("put " + x) - m send Full(x) + private val m = actor { + var buf: Option[Int] = None + loop { + react { + case Put(x) if buf.isEmpty => + println("put "+x); + buf = Some(x); reply() + case Get if !buf.isEmpty => + val x = buf.get + println("get "+x) + buf = None; reply(x) + } } } + m.start() - def read: Int = m receive { - case Full(x) => - println("get " + x) - m send Empty(); x - } + def write(x: Int) { m !? Put(x) } + + def read(): Int = (m !? Get).asInstanceOf[Int] } def kill(delay: Int) = new java.util.Timer().schedule( new java.util.TimerTask { - override def run() = { + override def run() { println("[killed]") - exit(0) + sys exit 0 } }, delay) // in milliseconds @@ -40,19 +44,19 @@ object oneplacebuffer { val random = new java.util.Random() def producer(n: Int) { - Thread.sleep(random.nextInt(1000)) - buf.write(n) + Thread.sleep(random nextInt 1000) + buf write n producer(n + 1) } def consumer { - Thread.sleep(random.nextInt(1000)) - val n = buf.read + Thread.sleep(random nextInt 1000) + val n = buf.read() consumer } - ops.spawn(producer(0)) - ops.spawn(consumer) + ops spawn producer(0) + ops spawn consumer kill(10000) } diff --git a/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala b/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala index 786d72d37..06fe669cb 100644 --- a/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala +++ b/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala @@ -26,7 +26,7 @@ extends Global(settings, reporter) { phasesSet += analyzer.typerFactory phasesSet += superAccessors // add super accessors phasesSet += pickler // serialize symbol tables - phasesSet += refchecks // perform reference and override checking, translate nested objects + phasesSet += refChecks // perform reference and override checking, translate nested objects for (phase <- TemplatePlugin.components(this)) { phasesSet += phase