blob: f0326f885da67a779461ce20a60a123b779230b4 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import scala.actors.MigrationSystem._
import scala.actors.Actor._
import scala.actors.{ Actor, StashingActor, ActorRef, Props, MigrationSystem, PoisonPill }
import java.util.concurrent.{ TimeUnit, CountDownLatch }
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.util.duration._
import scala.concurrent.{ Promise, Await }
object Test {
val finished = Promise[Boolean]
def testReactWithin() = {
val sActor = actor {
loop {
reactWithin(1) {
case scala.actors.TIMEOUT =>
println("received")
exit()
case _ =>
println("Should not occur.")
}
}
}
val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
context.setReceiveTimeout(1 millisecond)
def receive = {
case ReceiveTimeout =>
println("received")
finished.success(true)
context.stop(self)
case _ =>
println("Should not occur.")
}
}, "default-stashing-dispatcher"))
}
def main(args: Array[String]) = {
testReactWithin()
Await.ready(finished.future, 5 seconds)
}
}
|