diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:44:33 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:44:33 +0000 |
commit | 53a3cc7b17f4cf97075b7e71720777fd84109696 (patch) | |
tree | 0cc784e0b47ea49cc151a136d19f20bfa8ee2197 /sources/examples/oneplacebuffer.scala | |
parent | df50e05006b43b007c2587549030d24b5c154398 (diff) | |
download | scala-53a3cc7b17f4cf97075b7e71720777fd84109696.tar.gz scala-53a3cc7b17f4cf97075b7e71720777fd84109696.tar.bz2 scala-53a3cc7b17f4cf97075b7e71720777fd84109696.zip |
Created proper 'docs' folder for new layout.
Diffstat (limited to 'sources/examples/oneplacebuffer.scala')
-rw-r--r-- | sources/examples/oneplacebuffer.scala | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/sources/examples/oneplacebuffer.scala b/sources/examples/oneplacebuffer.scala deleted file mode 100644 index 7fa2ae8dba..0000000000 --- a/sources/examples/oneplacebuffer.scala +++ /dev/null @@ -1,47 +0,0 @@ -package examples; - -object oneplacebuffer { - - 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) - } - -} - |