RedissonCountDownLatch.await with timeout fixed

pull/6/head
Nikita 11 years ago
parent 9825ffa126
commit 207d89b34b

@ -88,17 +88,14 @@ public class RedissonCountDownLatch implements RCountDownLatch {
public boolean await(long time, TimeUnit unit) throws InterruptedException {
time = unit.toMillis(time);
while (getCount() > 0) {
if (time <= 0) {
return false;
}
long current = System.currentTimeMillis();
// waiting for message
boolean res = msg.tryAcquire(time, TimeUnit.MILLISECONDS);
if (res) {
return true;
}
msg.tryAcquire(time, TimeUnit.MILLISECONDS);
long elapsed = System.currentTimeMillis() - current;
time -= elapsed;
if (time <= 0) {
return false;
}
}
return true;
}

Loading…
Cancel
Save