summaryrefslogtreecommitdiff
path: root/docs/examples/actors/channels.scala
blob: 9267882e50defe3a3cc3bba5a376be4511f6d3f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package 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)

    react {
      case x => Console.println("received on int channel: "+x)
      //case y => Console.println("received on String channel: "+y)
    }
  }

  val b = actor {
    react {
      case Msg(ch1, ch2) => ch1 ! 42
    }
  }
}