diff options
author | michelou <michelou@epfl.ch> | 2004-02-23 13:08:11 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2004-02-23 13:08:11 +0000 |
commit | c2e3c0f366628a64e735686f3cd871843ea239c6 (patch) | |
tree | 5d7e08ce41e297611037016cefc676c393c18569 | |
parent | 192afdc3cafd6efc7ceb3deebf3f3591cb71c154 (diff) | |
download | scala-c2e3c0f366628a64e735686f3cd871843ea239c6.tar.gz scala-c2e3c0f366628a64e735686f3cd871843ea239c6.tar.bz2 scala-c2e3c0f366628a64e735686f3cd871843ea239c6.zip |
- example renamed to 'oneplacebuffer.scala'
-rw-r--r-- | sources/examples/buffer1.scala | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/sources/examples/buffer1.scala b/sources/examples/buffer1.scala deleted file mode 100644 index 2afb4377bf..0000000000 --- a/sources/examples/buffer1.scala +++ /dev/null @@ -1,46 +0,0 @@ -package examples; - -object buffer1 { - - import scala.concurrent._; - - class OnePlaceBuffer { - private val m = new MailBox(); // An internal mailbox - private case class Empty(), Full(x: Int); // Types of messages we deal with - - m send Empty(); // Initialization - - def write(x: Int): Unit = m receive { - case Empty() => - Console.println("put " + x); - m send Full(x) - } - - def read: Int = m receive { - case Full(x) => - Console.println("get " + x); - m send Empty() ; x - } - } - - def main(args: Array[String]) = { - val buf = new OnePlaceBuffer; - val random = new java.util.Random(); - - def producer(n: int): unit = { - Thread.sleep(random.nextInt(1000)); - buf.write(n); - producer(n + 1) - } - - def consumer: unit = { - Thread.sleep(random.nextInt(1000)); - val n = buf.read; - consumer - } - - ops.spawn(producer(0)); - ops.spawn(consumer) - } - -} |