diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-07-21 12:21:56 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-07-21 12:21:56 +0000 |
commit | 64342a3d920ea055739f94d1f10119bcfeabd12e (patch) | |
tree | df804581600d353d0f7d5d860fa55a69a27ea357 /test | |
parent | 2c3208955cbeacb21cb096237ae131af874e6db3 (diff) | |
download | scala-64342a3d920ea055739f94d1f10119bcfeabd12e.tar.gz scala-64342a3d920ea055739f94d1f10119bcfeabd12e.tar.bz2 scala-64342a3d920ea055739f94d1f10119bcfeabd12e.zip |
Enabled future-type message sends for reactors.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/replyablereactor.check | 5 | ||||
-rw-r--r-- | test/files/jvm/replyablereactor.scala | 47 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/files/jvm/replyablereactor.check b/test/files/jvm/replyablereactor.check new file mode 100644 index 0000000000..0944b17279 --- /dev/null +++ b/test/files/jvm/replyablereactor.check @@ -0,0 +1,5 @@ +'hello +'hello +'hello +'hello +'hello diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala new file mode 100644 index 0000000000..5c45c7fc54 --- /dev/null +++ b/test/files/jvm/replyablereactor.scala @@ -0,0 +1,47 @@ +import scala.actors._ +import scala.actors.Actor._ + +class MyActor extends ReplyReactor with ReplyableReactor { + def act() { + loop { + react { + case 'hello => + sender ! 'hello + case 'stop => + exit() + } + } + } +} + +object Test { + def main(args: Array[String]) { + val a = new MyActor + a.start() + + val b = new Reactor { + def act() { + react { + case r: MyActor => + var i = 0 + loop { + i += 1 + val ft = r !! 'hello + react { + case ft.inputChannel ! msg => + if (i % 10000 == 0) + println(msg) + if (i >= 50000) { + r ! 'stop + exit() + } + } + } + } + } + } + b.start() + + b ! a + } +} |