diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/actor-executor.check | 20 | ||||
-rw-r--r-- | test/files/jvm/actor-executor.scala | 59 | ||||
-rw-r--r-- | test/files/jvm/actor-executor2.check | 21 | ||||
-rw-r--r-- | test/files/jvm/actor-executor2.scala | 67 | ||||
-rw-r--r-- | test/files/jvm/actor-executor3.check | 20 | ||||
-rw-r--r-- | test/files/jvm/actor-executor3.scala | 52 | ||||
-rw-r--r-- | test/files/jvm/actor-executor4.check | 21 | ||||
-rw-r--r-- | test/files/jvm/actor-executor4.scala | 64 | ||||
-rw-r--r-- | test/files/jvm/reactor.scala | 2 |
9 files changed, 325 insertions, 1 deletions
diff --git a/test/files/jvm/actor-executor.check b/test/files/jvm/actor-executor.check new file mode 100644 index 0000000000..bdbdb5c6a2 --- /dev/null +++ b/test/files/jvm/actor-executor.check @@ -0,0 +1,20 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala new file mode 100644 index 0000000000..e650043382 --- /dev/null +++ b/test/files/jvm/actor-executor.scala @@ -0,0 +1,59 @@ +import java.util.concurrent.Executors +import scala.actors.{Actor, SchedulerAdapter} +import Actor._ + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < 10000) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % 1000 == 0) + println("One: OK") + if (i == 10000) + Test.executor.shutdown() + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < 10000) { + i += 1 + react { + case 'MsgForTwo => + if (i % 1000 == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +object Test { + val executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = + new SchedulerAdapter { + def execute(block: => Unit) { + executor.execute(new Runnable { + def run() { block } + }) + } + } + + def main(args: Array[String]) { + One.start() + } +} diff --git a/test/files/jvm/actor-executor2.check b/test/files/jvm/actor-executor2.check new file mode 100644 index 0000000000..da78f45836 --- /dev/null +++ b/test/files/jvm/actor-executor2.check @@ -0,0 +1,21 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +One exited diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala new file mode 100644 index 0000000000..9e99e167aa --- /dev/null +++ b/test/files/jvm/actor-executor2.scala @@ -0,0 +1,67 @@ +import scala.actors.{Actor, SchedulerAdapter, Exit} +import Actor._ +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 executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = + new SchedulerAdapter { + def execute(block: => Unit) { + executor.execute(new Runnable { + def run() { block } + }) + } + } + + def main(args: Array[String]) { + self.trapExit = true + link(One) + One.start() + + receive { + case Exit(from, reason) => + println("One exited") + Test.executor.shutdown() + } + } +} diff --git a/test/files/jvm/actor-executor3.check b/test/files/jvm/actor-executor3.check new file mode 100644 index 0000000000..bdbdb5c6a2 --- /dev/null +++ b/test/files/jvm/actor-executor3.check @@ -0,0 +1,20 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala new file mode 100644 index 0000000000..bf060b8ac5 --- /dev/null +++ b/test/files/jvm/actor-executor3.scala @@ -0,0 +1,52 @@ +import scala.actors.Actor +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 executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = ExecutorScheduler(executor) + + def main(args: Array[String]) { + One.start() + } +} diff --git a/test/files/jvm/actor-executor4.check b/test/files/jvm/actor-executor4.check new file mode 100644 index 0000000000..da78f45836 --- /dev/null +++ b/test/files/jvm/actor-executor4.check @@ -0,0 +1,21 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +One exited diff --git a/test/files/jvm/actor-executor4.scala b/test/files/jvm/actor-executor4.scala new file mode 100644 index 0000000000..a912d76094 --- /dev/null +++ b/test/files/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() + } +} diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala index 2fc54d8344..919263b65a 100644 --- a/test/files/jvm/reactor.scala +++ b/test/files/jvm/reactor.scala @@ -6,7 +6,7 @@ case object Pong case object Stop /** - * Ping pong example for OutputChannelActor. + * Ping pong example for Reactor. * * @author Philipp Haller */ |