•Agents communicate by exchanging names through channels (which are also names) •Connections between agents may change in the course of the computation
• The Agents: C = (νz) y(p).pz S = yx.S P = x(w).α.P • The composition: C | S | P & 6 3 \ [ _ _ EXAMPLE Example adapted from: An Introduction to the pi-Calculus, by Joachim Parrow
val y = Link[Link[String]] val x = Link[String] val C = Agent { val p = Name[Link[String]] y(p) * p~"message" } lazy val S:Agent = Agent { y~x*S } EXAMPLE S = yx.S _
val y = Link[Link[String]] val x = Link[String] val C = Agent { val p = Name[Link[String]] y(p) * p~"message" } lazy val S:Agent = Agent { y~x*S } lazy val P:Agent = Agent { val w = Name[String] val act = Action { println(msg.value) } x(w) * act * P } EXAMPLE P = x(w).α.P
val y = Link[Link[String]] val x = Link[String] val C = Agent { val p = Name[Link[String]] y(p) * p~"message" } lazy val S:Agent = Agent { y~x*S } lazy val P:Agent = Agent { val msg = Name[String] val act = Action { println(msg.value) } x(msg) * act * P } new ThreadedRunner(C | S | P) start EXAMPLE C | S | P
MESSAGE PASSING Output yx Input y(x) Wait until y is empty Wait until y is not empty Put x on y Put the contents of y in x Signal y not empty Signal y empty Wait until y is empty _
THREAD SPAWNING • CachedThreadPool • Caches finished threads • Reuses cached threads • Creates new threads if none are available • Deletes from the pool threads that have not been used reused for 60 seconds