summaryrefslogtreecommitdiff
path: root/docs/examples/boundedbuffer.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2010-11-17 12:26:13 +0000
committermichelou <michelou@epfl.ch>2010-11-17 12:26:13 +0000
commitc09f6173e96ec741c9b38edfee969ae8c6b74d4e (patch)
tree1f06579f72afa12092acd0b5bbb7c678291cf619 /docs/examples/boundedbuffer.scala
parent363a1456f671323b35dcacf2c8b8eb39180b8a53 (diff)
downloadscala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.tar.gz
scala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.tar.bz2
scala-c09f6173e96ec741c9b38edfee969ae8c6b74d4e.zip
updates Scala examples, added detach plugin
Diffstat (limited to 'docs/examples/boundedbuffer.scala')
-rw-r--r--docs/examples/boundedbuffer.scala8
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/examples/boundedbuffer.scala b/docs/examples/boundedbuffer.scala
index dceda62bd4..359bfd8d06 100644
--- a/docs/examples/boundedbuffer.scala
+++ b/docs/examples/boundedbuffer.scala
@@ -4,19 +4,19 @@ object boundedbuffer {
import concurrent.ops._
- class BoundedBuffer[a](N: Int) {
+ class BoundedBuffer[A](N: Int)(implicit m: ClassManifest[A]) {
var in, out, n = 0
- val elems = new Array[a](N)
+ val elems = new Array[A](N)
def await(cond: => Boolean) = while (!cond) { wait() }
- def put(x: a) = synchronized {
+ def put(x: A) = synchronized {
await (n < N)
elems(in) = x; in = (in + 1) % N; n += 1
if (n == 1) notifyAll()
}
- def get: a = synchronized {
+ def get: A = synchronized {
await (n != 0)
val x = elems(out); out = (out + 1) % N ; n -= 1
if (n == N - 1) notifyAll()