|
|
@ -110,6 +110,9 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
if (ttl == null) {
|
|
|
|
if (ttl == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ttl == Long.MIN_VALUE) {
|
|
|
|
|
|
|
|
throw new InterruptedException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CompletableFuture<RedissonLockEntry> future = subscribe(threadId);
|
|
|
|
CompletableFuture<RedissonLockEntry> future = subscribe(threadId);
|
|
|
|
pubSub.timeout(future);
|
|
|
|
pubSub.timeout(future);
|
|
|
@ -127,6 +130,9 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
if (ttl == null) {
|
|
|
|
if (ttl == null) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ttl == Long.MIN_VALUE) {
|
|
|
|
|
|
|
|
throw new InterruptedException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// waiting for message
|
|
|
|
// waiting for message
|
|
|
|
if (ttl >= 0) {
|
|
|
|
if (ttl >= 0) {
|
|
|
@ -157,7 +163,7 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private RFuture<Long> tryAcquireAsync0(long waitTime, long leaseTime, TimeUnit unit, long threadId) {
|
|
|
|
private RFuture<Long> tryAcquireAsync0(long waitTime, long leaseTime, TimeUnit unit, long threadId) {
|
|
|
|
return getServiceManager().execute(() -> tryAcquireAsync(waitTime, leaseTime, unit, threadId));
|
|
|
|
return getServiceManager().execute(() -> tryAcquireAsync(waitTime, leaseTime, unit, threadId), Long.MIN_VALUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private RFuture<Boolean> tryAcquireOnceAsync(long waitTime, long leaseTime, TimeUnit unit, long threadId) {
|
|
|
|
private RFuture<Boolean> tryAcquireOnceAsync(long waitTime, long leaseTime, TimeUnit unit, long threadId) {
|
|
|
@ -233,6 +239,9 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
long current = System.currentTimeMillis();
|
|
|
|
long current = System.currentTimeMillis();
|
|
|
|
long threadId = Thread.currentThread().getId();
|
|
|
|
long threadId = Thread.currentThread().getId();
|
|
|
|
Long ttl = tryAcquire(waitTime, leaseTime, unit, threadId);
|
|
|
|
Long ttl = tryAcquire(waitTime, leaseTime, unit, threadId);
|
|
|
|
|
|
|
|
if (ttl == Long.MIN_VALUE) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
// lock acquired
|
|
|
|
// lock acquired
|
|
|
|
if (ttl == null) {
|
|
|
|
if (ttl == null) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -280,6 +289,9 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
if (ttl == null) {
|
|
|
|
if (ttl == null) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ttl == Long.MIN_VALUE) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
time -= System.currentTimeMillis() - currentTime;
|
|
|
|
time -= System.currentTimeMillis() - currentTime;
|
|
|
|
if (time <= 0) {
|
|
|
|
if (time <= 0) {
|
|
|
@ -447,7 +459,7 @@ public class RedissonLock extends RedissonBaseLock {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public RFuture<Boolean> tryLockAsync(long threadId) {
|
|
|
|
public RFuture<Boolean> tryLockAsync(long threadId) {
|
|
|
|
return getServiceManager().execute(() -> tryAcquireOnceAsync(-1, -1, null, threadId));
|
|
|
|
return getServiceManager().execute(() -> tryAcquireOnceAsync(-1, -1, null, threadId), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|