diff options
-rw-r--r-- | test/files/jvm/scheduler-adapter.check | 6 | ||||
-rw-r--r-- | test/files/jvm/scheduler-adapter.scala | 41 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/files/jvm/scheduler-adapter.check b/test/files/jvm/scheduler-adapter.check new file mode 100644 index 0000000000..b278674cf0 --- /dev/null +++ b/test/files/jvm/scheduler-adapter.check @@ -0,0 +1,6 @@ +before +before +before +Two: received msg +before +One: received msg diff --git a/test/files/jvm/scheduler-adapter.scala b/test/files/jvm/scheduler-adapter.scala new file mode 100644 index 0000000000..79c901f91e --- /dev/null +++ b/test/files/jvm/scheduler-adapter.scala @@ -0,0 +1,41 @@ +import scala.actors.{Actor, SchedulerAdapter} + +trait AdaptedActor extends Actor { + override def scheduler = + Test.adapted +} + +object One extends AdaptedActor { + def act() { + Two.start() + Two ! 'MsgForTwo + react { + case 'MsgForOne => + println("One: received msg") + } + } +} + +object Two extends AdaptedActor { + def act() { + react { + case 'MsgForTwo => + println("Two: received msg") + One ! 'MsgForOne + } + } +} + +object Test { + val adapted = + new SchedulerAdapter { + def execute(block: => Unit) { + println("before") + block + } + } + + def main(args: Array[String]) { + One.start() + } +} |