CommandAsyncService.get method optimization

pull/653/head
Nikita 8 years ago
parent 02adac8564
commit dd93ebbe0d

@ -118,25 +118,27 @@ public class CommandAsyncService implements CommandAsyncExecutor {
@Override @Override
public <V> V get(RFuture<V> future) { public <V> V get(RFuture<V> future) {
final CountDownLatch l = new CountDownLatch(1); if (!future.isDone()) {
future.addListener(new FutureListener<V>() { final CountDownLatch l = new CountDownLatch(1);
@Override future.addListener(new FutureListener<V>() {
public void operationComplete(Future<V> future) throws Exception { @Override
l.countDown(); public void operationComplete(Future<V> future) throws Exception {
} l.countDown();
}); }
});
boolean interrupted = false; boolean interrupted = false;
while (!future.isDone()) { while (!future.isDone()) {
try { try {
l.await(); l.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
interrupted = true; interrupted = true;
}
} }
}
if (interrupted) { if (interrupted) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
}
} }
// commented out due to blocking issues up to 200 ms per minute for each thread // commented out due to blocking issues up to 200 ms per minute for each thread

Loading…
Cancel
Save