diff options
author | Philipp Haller <hallerp@gmail.com> | 2010-03-09 14:03:02 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2010-03-09 14:03:02 +0000 |
commit | c3d86bfed31856f8b82348ee7fe64e46fd6bd098 (patch) | |
tree | dda59709c1dafb55dc75ba1b7acd9d460702f762 /test/pending/jvm/actor-executor4.scala | |
parent | 0708b61d19f1d69f4017d0f4a5778ed805c0922b (diff) | |
download | scala-c3d86bfed31856f8b82348ee7fe64e46fd6bd098.tar.gz scala-c3d86bfed31856f8b82348ee7fe64e46fd6bd098.tar.bz2 scala-c3d86bfed31856f8b82348ee7fe64e46fd6bd098.zip |
New attempt at fixing the tests. No review.
Diffstat (limited to 'test/pending/jvm/actor-executor4.scala')
-rw-r--r-- | test/pending/jvm/actor-executor4.scala | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/pending/jvm/actor-executor4.scala b/test/pending/jvm/actor-executor4.scala new file mode 100644 index 0000000000..a912d76094 --- /dev/null +++ b/test/pending/jvm/actor-executor4.scala @@ -0,0 +1,64 @@ +import scala.actors.{Actor, Exit} +import scala.actors.scheduler.ExecutorScheduler +import java.util.concurrent.Executors + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % (Test.NUM_MSG/10) == 0) + println("One: OK") + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + react { + case 'MsgForTwo => + if (i % (Test.NUM_MSG/10) == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object Test { + val NUM_MSG = 100000 + + val scheduler = + ExecutorScheduler( + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), + false) + + def main(args: Array[String]) { + (new AdaptedActor { + def act() { + trapExit = true + link(One) + One.start() + + receive { + case Exit(from, reason) => + println("One exited") + Test.scheduler.shutdown() + } + } + }).start() + } +} |