make relocking with different modes work
All checks were successful
/ Build & Publish (push) Successful in 44s
All checks were successful
/ Build & Publish (push) Successful in 44s
This commit is contained in:
parent
8fd30ea15d
commit
28dfebea25
1 changed files with 19 additions and 22 deletions
|
@ -56,16 +56,14 @@ public class Lock extends SimpleLock {
|
|||
* Wait until unlocked, either by a timer or manually
|
||||
*/
|
||||
public synchronized void waitHere() {
|
||||
if(!isTimed) {
|
||||
do
|
||||
super.waitHere();
|
||||
while(relocking);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!super.isLocked())
|
||||
return;
|
||||
|
||||
do {
|
||||
if(!isTimed) {
|
||||
super.waitHere();
|
||||
continue;
|
||||
}
|
||||
long wt = timeLeft0();
|
||||
if(wt == 0) {
|
||||
unlock();
|
||||
|
@ -82,30 +80,29 @@ public class Lock extends SimpleLock {
|
|||
public synchronized void waitHere(int timeout) {
|
||||
if(timeout == 0)
|
||||
return;
|
||||
long start = System.currentTimeMillis();
|
||||
if(!isTimed) {
|
||||
do {
|
||||
long sectionOffset = System.currentTimeMillis() - start;
|
||||
long wt = timeout - sectionOffset;
|
||||
if(wt == 0)
|
||||
break;
|
||||
super.waitHere(wt);
|
||||
} while(relocking);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!super.isLocked())
|
||||
return;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
do {
|
||||
long sectionOffset = System.currentTimeMillis() - start;
|
||||
|
||||
if(!isTimed) {
|
||||
long wt = timeout - sectionOffset;
|
||||
if(wt <= 0)
|
||||
return;
|
||||
super.waitHere(wt);
|
||||
continue;
|
||||
}
|
||||
|
||||
long wt = timeLeft0();
|
||||
if(wt == 0) {
|
||||
unlock();
|
||||
return;
|
||||
}
|
||||
long sectionOffset = System.currentTimeMillis() - start;
|
||||
wt = Math.min(wt, timeout - sectionOffset);
|
||||
if(wt == 0)
|
||||
break;
|
||||
if(wt <= 0)
|
||||
return;
|
||||
super.waitHere(wt);
|
||||
} while(relocking);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue