diff options
Diffstat (limited to 'docs/examples/jolib')
-rw-r--r-- | docs/examples/jolib/Ref.scala | 55 | ||||
-rw-r--r-- | docs/examples/jolib/parallelOr.scala | 58 |
2 files changed, 0 insertions, 113 deletions
diff --git a/docs/examples/jolib/Ref.scala b/docs/examples/jolib/Ref.scala deleted file mode 100644 index 5f655f16b1..0000000000 --- a/docs/examples/jolib/Ref.scala +++ /dev/null @@ -1,55 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package examples.jolib; -/* -import concurrent.SyncVar; -import concurrent.jolib._; - -class Ref[a](init: a) extends Join { - - object get extends Synchr[a](this) { case class C() extends SyncVar[a]; } - object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; } - object state extends Asynchr(this) { case class C(x: a); } - - rules ( - Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) => - { g.set(x); state(state.C(x)) } }), - Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) => - { s.set(()); state(state.C(x)) } }) - ); - - state(state.C(init)); - - def Get: a = get(get.C()); - def Set(x: a): unit = set(set.C(x)); -} -*/ -object RefTest { - - def main(args: Array[String]) = { - System.out.println("Started."); -/* - concurrent.ops.spawn({ - val r1 = new Ref(0); - System.out.println("Reference r1 created."); - System.out.println("Value r1 (first time) = " + r1.Get); - r1.Set(42); - System.out.println("Value r1 (second time) = " + r1.Get); - }); - concurrent.ops.spawn({ - val r2 = new Ref(100); - System.out.println("Reference r2 created."); - System.out.println("Value r2 (first time) = " + r2.Get); - r2.Set(89); - System.out.println("Value r2 (second time) = " + r2.Get); - }); -*/ - } - -} diff --git a/docs/examples/jolib/parallelOr.scala b/docs/examples/jolib/parallelOr.scala deleted file mode 100644 index 72d282bee3..0000000000 --- a/docs/examples/jolib/parallelOr.scala +++ /dev/null @@ -1,58 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package examples.jolib; -/* -import concurrent.jolib._; -import concurrent.SyncVar; - -/** Implementation in the join-calculus of a parallel OR. */ -object or extends Join { - - object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; - object res1 extends Asynchr(this) { case class C(b: boolean); } - object res2 extends Asynchr(this) { case class C(b: boolean); } - object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; - object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] }; - - rules( - Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) => - if (b) r.set(b) else r.set(res1False(res1False.C())) }), - - Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) => - if (b) r.set(b) else r.set(res2False(res2False.C())) }), - - Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) => - r.set(b) }), - - Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) => - r.set(b) }) - ); - - def apply(b1: => boolean, b2: => boolean): boolean = { - concurrent.ops.spawn(res1(res1.C(b1))); - concurrent.ops.spawn(res2(res2.C(b2))); - res(res.C()) - } -} -*/ -object parallelOr { - - def main(args: Array[String]): unit = { - def loop: boolean = { while (true) {}; true }; -/* - System.out.println("true || true = " + or(true, true)); - System.out.println("false || false = " + or(false, false)); - System.out.println("false || true = " + or(false, true)); - System.out.println("true || false = " + or(true, false)); - System.out.println("true || loop = " + or(true, loop)); - System.out.println("loop || true = " + or(loop, true)); -*/ - } - -} |