diff options
author | michelou <michelou@epfl.ch> | 2006-02-22 17:54:31 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-02-22 17:54:31 +0000 |
commit | 96ae92e4f6f830a9a4e55768c3de0328a2a030ba (patch) | |
tree | 0b84d247c1693bf186787aaa8f0c75d89fea9be3 /docs/examples/pilib/twoPlaceBuffer.scala | |
parent | c1e184a3657d970a8fba6e3c7049f20a2e466bf0 (diff) | |
download | scala-96ae92e4f6f830a9a4e55768c3de0328a2a030ba.tar.gz scala-96ae92e4f6f830a9a4e55768c3de0328a2a030ba.tar.bz2 scala-96ae92e4f6f830a9a4e55768c3de0328a2a030ba.zip |
adapted code to Scala 2 syntax in files src/exa...
adapted code to Scala 2 syntax in files src/examples/**/*.scala
Diffstat (limited to 'docs/examples/pilib/twoPlaceBuffer.scala')
-rw-r--r-- | docs/examples/pilib/twoPlaceBuffer.scala | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/docs/examples/pilib/twoPlaceBuffer.scala b/docs/examples/pilib/twoPlaceBuffer.scala index 686547b344..020f3e4992 100644 --- a/docs/examples/pilib/twoPlaceBuffer.scala +++ b/docs/examples/pilib/twoPlaceBuffer.scala @@ -1,53 +1,53 @@ -package examples.pilib; +package examples.pilib -import scala.concurrent.pilib._; +import scala.concurrent.pilib._ /** Two-place buffer specification and implementation. */ -object twoPlaceBuffer with Application { +object twoPlaceBuffer extends Application { /** - * Specification. - */ - def Spec[a](in: Chan[a], out: Chan[a]): unit = { + * Specification. + */ + def Spec[a](in: Chan[a], out: Chan[a]): Unit = { def B0: unit = choice ( in * (x => B1(x)) - ); + ) def B1(x: a): unit = choice ( out(x) * (B0), in * (y => B2(x, y)) - ); + ) def B2(x: a, y: a): unit = choice ( out(x) * (B1(y)) - ); + ) B0 } /** - * Implementation using two one-place buffers. - */ + * Implementation using two one-place buffers. + */ def Impl[a](in: Chan[a], out: Chan[a]): unit = { ///- ... complete here ... // one-place buffer - def OnePlaceBuffer[a](in: Chan[a], out: Chan[a]): unit = { - def B0: unit = choice ( in * (x => B1(x)) ); - def B1(x: a): unit = choice ( out(x) * (B0)); + def OnePlaceBuffer[a](in: Chan[a], out: Chan[a]): Unit = { + def B0: unit = choice ( in * (x => B1(x)) ) + def B1(x: a): unit = choice ( out(x) * (B0)) B0 } - val hidden = new Chan[a]; + val hidden = new Chan[a] spawn < OnePlaceBuffer(in, hidden) | OnePlaceBuffer(hidden, out) > ///+ } - val random = new java.util.Random(); + val random = new java.util.Random() - def Producer(n: Int, in: Chan[String]): unit = { - Thread.sleep(random.nextInt(1000)); - val msg = "" + n; - choice (in(msg) * {}); + def Producer(n: Int, in: Chan[String]): Unit = { + Thread.sleep(random.nextInt(1000)) + val msg = "" + n + choice (in(msg) * {}) Producer(n + 1, in) } @@ -57,10 +57,10 @@ object twoPlaceBuffer with Application { Consumer(out) } - val in = new Chan[String]; - in.attach(s => System.out.println("put " + s)); - val out = new Chan[String]; - out.attach(s => System.out.println("get " + s)); + val in = new Chan[String] + in.attach(s => System.out.println("put " + s)) + val out = new Chan[String] + out.attach(s => System.out.println("get " + s)) //spawn < Producer(0, in) | Consumer(out) | Spec(in, out) > spawn < Producer(0, in) | Consumer(out) | Impl(in, out) > |