|
Scala example source code file (channels.scala)
The Scala channels.scala source codepackage examples.actors import scala.actors._ import scala.actors.Actor._ object channels extends Application { case class Msg(ch1: Channel[Int], ch2: Channel[String]) val a = actor { val Ch1 = new Channel[Int] val Ch2 = new Channel[String] b ! Msg(Ch1, Ch2) val ICh1 = Ch1.asInstanceOf[InputChannel[Int]] val ICh2 = Ch2.asInstanceOf[InputChannel[String]] react { case ICh1 ! (x: Int) => val r = x + 21 println("result: "+r) case ICh2 ! y => println("received: "+y) } } val b = actor { react { case Msg(ch1, ch2) => ch1 ! 21 } } } Other Scala examples (source code examples)Here is a short list of links related to this Scala channels.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.