Replace sleep with latch in valueWithin test
This commit is contained in:
parent
d8c07d05e8
commit
fb8625ce5f
1 changed files with 5 additions and 2 deletions
|
|
@ -277,14 +277,17 @@ class FutureSpec extends JUnitSuite {
|
|||
}
|
||||
|
||||
@Test def resultWithinShouldNotThrowExceptions {
|
||||
val latch = new StandardLatch
|
||||
|
||||
val actors = (1 to 10).toList map { _ =>
|
||||
actorOf(new Actor {
|
||||
def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add }
|
||||
def receive = { case (add: Int, wait: Boolean, latch: StandardLatch) => if (wait) latch.await; self reply_? add }
|
||||
}).start
|
||||
}
|
||||
|
||||
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!! 5000 else 0 )) }
|
||||
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!) }
|
||||
val result = for(f <- futures) yield f.valueWithin(2, TimeUnit.SECONDS)
|
||||
latch.open
|
||||
val done = result collect { case Some(Right(x)) => x }
|
||||
val undone = result collect { case None => None }
|
||||
val errors = result collect { case Some(Left(t)) => t }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue