diff options
Diffstat (limited to 'sources')
-rw-r--r-- | sources/examples/jolib/Ref.scala | 10 | ||||
-rw-r--r-- | sources/examples/jolib/parallelOr.scala | 10 | ||||
-rw-r--r-- | sources/scala/concurrent/jolib.scala | 27 |
3 files changed, 12 insertions, 35 deletions
diff --git a/sources/examples/jolib/Ref.scala b/sources/examples/jolib/Ref.scala index 5e2b955bb7..d48a9ee8f3 100644 --- a/sources/examples/jolib/Ref.scala +++ b/sources/examples/jolib/Ref.scala @@ -9,15 +9,15 @@ class Ref[a](init: a) extends Join { rules ( Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) => - { g.set(x); state.send(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.send(state.C(x)) } }) + { s.set(()); state(state.C(x)) } }) ); - state.send(state.C(init)); + state(state.C(init)); - def Get: a = get.send(get.C()); - def Set(x: a): unit = set.send(set.C(x)); + def Get: a = get(get.C()); + def Set(x: a): unit = set(set.C(x)); } object RefTest { diff --git a/sources/examples/jolib/parallelOr.scala b/sources/examples/jolib/parallelOr.scala index 40abcc0a87..257733c855 100644 --- a/sources/examples/jolib/parallelOr.scala +++ b/sources/examples/jolib/parallelOr.scala @@ -12,10 +12,10 @@ object or extends Join { rules( Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) => - if (b) r.set(b) else r.set(res1False.send(res1False.C())) }), + 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.send(res2False.C())) }), + 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) }), @@ -25,9 +25,9 @@ object or extends Join { ); def apply(def b1: boolean, def b2: boolean): boolean = { - concurrent.ops.spawn(res1.send(res1.C(b1))); - concurrent.ops.spawn(res2.send(res2.C(b2))); - res.send(res.C()) + concurrent.ops.spawn(res1(res1.C(b1))); + concurrent.ops.spawn(res2(res2.C(b2))); + res(res.C()) } } diff --git a/sources/scala/concurrent/jolib.scala b/sources/scala/concurrent/jolib.scala index 7ca1da8dca..c02f2071ae 100644 --- a/sources/scala/concurrent/jolib.scala +++ b/sources/scala/concurrent/jolib.scala @@ -69,12 +69,12 @@ object jolib { } abstract class Asynchr(join: Join) extends Signal(join) { - def send(x: C): unit = tryReduction(x); + def apply(x: C): unit = tryReduction(x); } abstract class Synchr[a](join: Join) extends Signal(join) { type C <: SyncVar[a]; - def send(x: C): a = { + def apply(x: C): a = { tryReduction(x); x.get } @@ -82,26 +82,3 @@ object jolib { } -/* Example: References. (It does not work because of bugs in the compiler) - -import concurrent.jolib._; -import concurrent.SyncVar; - -class Ref(init: int) extends Join { - - object get extends Synchr[int](this) { case class C() extends SyncVar[int]; } - object set extends Synchr[unit](this) { case class C(x: int) extends SyncVar[unit]; } - object state extends Asynchr(this) { case class C(x: int); } - - rules ( - Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) => { g.set(x); state.send(state.C(x)) } }), - Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) => { s.set(()); state.send(state.C(x)) } }) - ); - - state.send(state.C(init)); - - def Get: int = get.send(get.C()); - def Set(x: int): unit = set.send(set.C(x)); -} -*/ - |