diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-10 11:14:46 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-10 11:14:46 -0800 |
commit | f40541788957c257ee8b4035e0063a8a48945c11 (patch) | |
tree | df574bd0aefe1e809fb890e42cdf2bf189659cfa /docs/examples/oneplacebuffer.scala | |
parent | 0c927046dc5df974e6c39187107cf3548825282b (diff) | |
parent | 27a38602decb891399fc9868b4dd7135f6e1ec2c (diff) | |
download | scala-f40541788957c257ee8b4035e0063a8a48945c11.tar.gz scala-f40541788957c257ee8b4035e0063a8a48945c11.tar.bz2 scala-f40541788957c257ee8b4035e0063a8a48945c11.zip |
Merge pull request #3248 from adriaanm/dist-cleanup-licenses
Clean up Scala distribution a bit.
Diffstat (limited to 'docs/examples/oneplacebuffer.scala')
-rw-r--r-- | docs/examples/oneplacebuffer.scala | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/docs/examples/oneplacebuffer.scala b/docs/examples/oneplacebuffer.scala deleted file mode 100644 index f7047a1c92..0000000000 --- a/docs/examples/oneplacebuffer.scala +++ /dev/null @@ -1,64 +0,0 @@ -package examples - -object oneplacebuffer { - - import scala.actors.Actor._ - import scala.concurrent.ops - - class OnePlaceBuffer { - private case class Put(x: Int) - private case object Get - - 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 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() { - println("[killed]") - sys exit 0 - } - }, - delay) // in milliseconds - - def main(args: Array[String]) { - val buf = new OnePlaceBuffer - val random = new java.util.Random() - - def producer(n: Int) { - Thread.sleep(random nextInt 1000) - buf write n - producer(n + 1) - } - - def consumer { - Thread.sleep(random nextInt 1000) - val n = buf.read() - consumer - } - - ops spawn producer(0) - ops spawn consumer - kill(10000) - } - -} - |