|
|
|
@ -575,12 +575,11 @@ public class RedissonLock extends RedissonExpirable implements RLock {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// waiting for message
|
|
|
|
|
final RedissonLockEntry entry = getEntry(currentThreadId);
|
|
|
|
|
synchronized (entry) {
|
|
|
|
|
if (entry.getLatch().tryAcquire()) {
|
|
|
|
|
lockAsync(leaseTime, unit, subscribeFuture, result, currentThreadId);
|
|
|
|
|
} else {
|
|
|
|
|
// waiting for message
|
|
|
|
|
final AtomicReference<Timeout> futureRef = new AtomicReference<Timeout>();
|
|
|
|
|
final Runnable listener = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
@ -598,18 +597,15 @@ public class RedissonLock extends RedissonExpirable implements RLock {
|
|
|
|
|
Timeout scheduledFuture = commandExecutor.getConnectionManager().newTimeout(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run(Timeout timeout) throws Exception {
|
|
|
|
|
synchronized (entry) {
|
|
|
|
|
if (entry.removeListener(listener)) {
|
|
|
|
|
lockAsync(leaseTime, unit, subscribeFuture, result, currentThreadId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, ttl, TimeUnit.MILLISECONDS);
|
|
|
|
|
futureRef.set(scheduledFuture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -768,7 +764,6 @@ public class RedissonLock extends RedissonExpirable implements RLock {
|
|
|
|
|
// waiting for message
|
|
|
|
|
final long current = System.currentTimeMillis();
|
|
|
|
|
final RedissonLockEntry entry = getEntry(currentThreadId);
|
|
|
|
|
synchronized (entry) {
|
|
|
|
|
if (entry.getLatch().tryAcquire()) {
|
|
|
|
|
tryLockAsync(time, leaseTime, unit, subscribeFuture, result, currentThreadId);
|
|
|
|
|
} else {
|
|
|
|
@ -798,7 +793,6 @@ public class RedissonLock extends RedissonExpirable implements RLock {
|
|
|
|
|
Timeout scheduledFuture = commandExecutor.getConnectionManager().newTimeout(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run(Timeout timeout) throws Exception {
|
|
|
|
|
synchronized (entry) {
|
|
|
|
|
if (entry.removeListener(listener)) {
|
|
|
|
|
long elapsed = System.currentTimeMillis() - current;
|
|
|
|
|
time.addAndGet(-elapsed);
|
|
|
|
@ -806,13 +800,11 @@ public class RedissonLock extends RedissonExpirable implements RLock {
|
|
|
|
|
tryLockAsync(time, leaseTime, unit, subscribeFuture, result, currentThreadId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, t, TimeUnit.MILLISECONDS);
|
|
|
|
|
futureRef.set(scheduledFuture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|