diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-02-02 15:17:51 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-02-02 15:17:51 +0000 |
commit | 7cc5c06947e40236ee16a6a09d3de524183fda86 (patch) | |
tree | 8b22f79f79ffcb4b8485a3c6b21380efdc66d903 /docs/examples/actors/BoundedBufferTest.scala | |
parent | 8c1bbafee4c68ccd158786deb4643d5a3074ce0d (diff) | |
download | scala-7cc5c06947e40236ee16a6a09d3de524183fda86.tar.gz scala-7cc5c06947e40236ee16a6a09d3de524183fda86.tar.bz2 scala-7cc5c06947e40236ee16a6a09d3de524183fda86.zip |
Cleaned-up actor examples.
Diffstat (limited to 'docs/examples/actors/BoundedBufferTest.scala')
-rw-r--r-- | docs/examples/actors/BoundedBufferTest.scala | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/docs/examples/actors/BoundedBufferTest.scala b/docs/examples/actors/BoundedBufferTest.scala deleted file mode 100644 index 7585d8779a..0000000000 --- a/docs/examples/actors/BoundedBufferTest.scala +++ /dev/null @@ -1,33 +0,0 @@ -package examples.actors - -import scala.actors.Actor._ - -object boundedbuffer { - class BoundedBuffer[T](N: int) { - private case class Get - private case class Put(x: T) - - private val buffer = actor { - val buf = new Array[T](N) - var in = 0; var out = 0; var n = 0 - while(true) { - receive { - case Put(x) if n < N => - buf(in) = x; in = (in + 1) % N; n = n + 1; reply() - case Get() if n > 0 => - val r = buf(out); out = (out + 1) % N; n = n - 1; reply(r) - } - } - } - - def put(x: T): Unit = buffer !? Put(x) - - def get: T = (buffer !? Get()).asInstanceOf[T] - } - - def main(args: Array[String]) = { - val buf = new BoundedBuffer[Int](1) - buf.put(42) - scala.Console.println("" + buf.get) - } -} |