in BoltsTest/src/bolts/TaskTest.java [462:483]
public void testContinueWhileAsync() {
final AtomicInteger count = new AtomicInteger(0);
runTaskTest(new Callable<Task<?>>() {
public Task<?> call() throws Exception {
return Task.forResult(null).continueWhile(new Callable<Boolean>() {
public Boolean call() throws Exception {
return count.get() < 10;
}
}, new Continuation<Void, Task<Void>>() {
public Task<Void> then(Task<Void> task) throws Exception {
count.incrementAndGet();
return null;
}
}, Executors.newCachedThreadPool()).continueWith(new Continuation<Void, Void>() {
public Void then(Task<Void> task) throws Exception {
assertEquals(10, count.get());
return null;
}
});
}
});
}