diff options
Diffstat (limited to 'docs/examples/pilib')
-rw-r--r-- | docs/examples/pilib/elasticBuffer.scala | 8 | ||||
-rw-r--r-- | docs/examples/pilib/handover.scala | 38 | ||||
-rw-r--r-- | docs/examples/pilib/piNat.scala | 16 |
3 files changed, 31 insertions, 31 deletions
diff --git a/docs/examples/pilib/elasticBuffer.scala b/docs/examples/pilib/elasticBuffer.scala index 5fec96ab6c..c173735dbb 100644 --- a/docs/examples/pilib/elasticBuffer.scala +++ b/docs/examples/pilib/elasticBuffer.scala @@ -8,7 +8,7 @@ object elasticBuffer { * Recursive type for channels that carry a "String" channel and * an object of the type we define. */ - class MetaChan extends Chan[Pair[Chan[String], MetaChan]] + class MetaChan extends Chan[Tuple2[Chan[String], MetaChan]] def Buffer(put: Chan[String], get: Chan[String]): Unit = { @@ -18,19 +18,19 @@ object elasticBuffer { def Bl(i:Chan[String], l: MetaChan, o: Chan[String], r: MetaChan): unit = choice ( - l(Pair(o,r)) * (System.out.println("Removed one cell.")), + l((o,r)) * (System.out.println("Removed one cell.")), i * (inp => Cl(i, l, o, r, inp)) ) /** * A buffer cell containing a value, ready to receive (o,r) from the right. */ - def Cl(i: Chan[String], l: MetaChan, + def Cl(i: Chan[String], l: MetaChan, o: Chan[String], r: MetaChan, content: String): Unit = choice ( o(content) * (Bl(i,l,o,r)), i * (inp => Dl(i,l,o,r,content, inp)), - r * ( { case Pair(newo, newr) => Cl(i,l,newo,newr,content) }) + r * ( { case (newo, newr) => Cl(i,l,newo,newr,content) }) ) /** diff --git a/docs/examples/pilib/handover.scala b/docs/examples/pilib/handover.scala index c9b6156c2c..4e9a5670a0 100644 --- a/docs/examples/pilib/handover.scala +++ b/docs/examples/pilib/handover.scala @@ -13,14 +13,14 @@ object handoverRecursive { * Recursive type for channels that carry a channel "unit" and * an object of the type we define. */ - class Switch extends Chan[Pair[Chan[unit], Switch]] + class Switch extends Chan[Tuple2[Chan[unit], Switch]] /** * Car. */ def Car(talk: Chan[unit], switch: Switch): unit = choice ( - switch * ({ case Pair(t,s) => Car(t, s) }), + switch * ({ case (t,s) => Car(t, s) }), talk(()) * ( { Thread.sleep(1 + random.nextInt(1000)); System.out.println("Car emitted a message."); @@ -32,20 +32,20 @@ object handoverRecursive { * Control center. */ def Control(talk1: Chan[unit], switch1: Switch, - gain1: Switch, lose1: Switch, + gain1: Switch, lose1: Switch, talk2: Chan[unit], switch2: Switch, gain2: Switch, lose2: Switch): unit = { def Control1: unit= { Thread.sleep(1 + random.nextInt(1000)); - lose1.write(Pair(talk2, switch2)); - gain2.write(Pair(talk2, switch2)); + lose1.write((talk2, switch2)); + gain2.write((talk2, switch2)); Control2 } def Control2: unit = { Thread.sleep(1 + random.nextInt(1000)); - lose2.write(Pair(talk1, switch1)); - gain1.write(Pair(talk1, switch1)); + lose2.write((talk1, switch1)); + gain1.write((talk1, switch1)); Control1 } Control1 @@ -62,8 +62,8 @@ object handoverRecursive { System.out.println(id + " received a message.") ActiveTransmitter(id, talk, switch, gain, lose) }), - lose * ({ case Pair(t, s) => { - switch.write(Pair(t, s)) + lose * ({ case (t, s) => { + switch.write((t, s)) IdleTransmitter(id, gain, lose) }}) ); @@ -72,7 +72,7 @@ object handoverRecursive { * Idle transmitter. */ def IdleTransmitter(id: String, gain: Switch, lose: Switch): unit = { - val Pair(t, s) = gain.read; + val (t, s) = gain.read; ActiveTransmitter(id, t, s, gain, lose) } @@ -108,7 +108,7 @@ object handoverCast { def Car(talk: Chan[Any], switch: Chan[Any]): unit = choice ( switch * (o => { - val Pair(t,s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]]; + val (t,s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]; Car(t, s) }), talk(()) * ( { @@ -122,20 +122,20 @@ object handoverCast { * Control center. */ def Control(talk1: Chan[Any], switch1: Chan[Any], - gain1: Chan[Any], lose1: Chan[Any], + gain1: Chan[Any], lose1: Chan[Any], talk2: Chan[Any], switch2: Chan[Any], gain2: Chan[Any], lose2: Chan[Any]): unit = { def Control1: unit = { Thread.sleep(1 + random.nextInt(1000)); - lose1.write(Pair(talk2, switch2)); - gain2.write(Pair(talk2, switch2)); + lose1.write((talk2, switch2)); + gain2.write((talk2, switch2)); Control2 } def Control2: unit = { Thread.sleep(1 + random.nextInt(1000)); - lose2.write(Pair(talk1, switch1)); - gain1.write(Pair(talk1, switch1)); + lose2.write((talk1, switch1)); + gain1.write((talk1, switch1)); Control1 } Control1 @@ -153,8 +153,8 @@ object handoverCast { ActiveTransmitter(id, talk, switch, gain, lose) }), lose * (o => { - val Pair(t, s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]] - switch.write(Pair(t, s)) + val (t, s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]] + switch.write((t, s)) IdleTransmitter(id, gain, lose) }) ) @@ -163,7 +163,7 @@ object handoverCast { * Idle transmitter. */ def IdleTransmitter(id: String, gain: Chan[Any], lose: Chan[Any]): unit = { - val Pair(t, s) = gain.read.asInstanceOf[Pair[Chan[Any],Chan[Any]]] + val (t, s) = gain.read.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]] ActiveTransmitter(id, t, s, gain, lose) } diff --git a/docs/examples/pilib/piNat.scala b/docs/examples/pilib/piNat.scala index a1a0e682e1..c6d9bdaf5c 100644 --- a/docs/examples/pilib/piNat.scala +++ b/docs/examples/pilib/piNat.scala @@ -4,23 +4,23 @@ import scala.concurrent.pilib._ /** Church encoding of naturals in the Pi-calculus */ object piNat extends Application { - + /** Locations of Pi-calculus natural */ - class NatChan extends Chan[Triple[Chan[Unit], Chan[NatChan], Chan[NatChan]]] + class NatChan extends Chan[Tuple3[Chan[Unit], Chan[NatChan], Chan[NatChan]]] /** Zero */ def Z(l: NatChan): Unit = choice ( - l * { case Triple(z, sd, d) => z.write(()) } + l * { case (z, sd, d) => z.write(()) } ) /** Successor of Double */ def SD(n: NatChan, l: NatChan): Unit = choice ( - l * { case Triple(z, sd, d) => sd.write(n) } + l * { case (z, sd, d) => sd.write(n) } ) /** Double */ def D(n: NatChan, l: NatChan): Unit = choice ( - l * { case Triple(z, sd, d) => d.write(n) } + l * { case (z, sd, d) => d.write(n) } ) /** Make "l" a location representing the natural "n" */ @@ -34,7 +34,7 @@ object piNat extends Application { val z = new Chan[Unit] val sd = new Chan[NatChan] val d = new Chan[NatChan] - spawn < m.write(Triple(z, sd, d)) >; + spawn < m.write((z, sd, d)) >; choice ( z * { x => make(1, n) }, sd * { m1 => { val n1 = new NatChan; spawn < D(n1, n) >; Succ(m1, n1) } }, @@ -47,7 +47,7 @@ object piNat extends Application { val z = new Chan[Unit] val sd = new Chan[NatChan] val d = new Chan[NatChan] - spawn < l.write(Triple(z, sd, d)) >; + spawn < l.write((z, sd, d)) >; choice ( z * { x => spawn < Z(m) >; Z(n) }, sd * { l1 => { val m1 = new NatChan; val n1 = new NatChan; @@ -64,7 +64,7 @@ object piNat extends Application { val z = new Chan[Unit] val sd = new Chan[NatChan] val d = new Chan[NatChan] - spawn < n.write(Triple(z, sd, d)) >; + spawn < n.write((z, sd, d)) >; choice ( z * { x => 0 }, sd * { n1 => 2 * value(n1) + 1 }, |