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
|
* Wait until unlocked, either by a timer or manually
|
||||||
*/
|
*/
|
||||||
public synchronized void waitHere() {
|
public synchronized void waitHere() {
|
||||||
if(!isTimed) {
|
|
||||||
do
|
|
||||||
super.waitHere();
|
|
||||||
while(relocking);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!super.isLocked())
|
if(!super.isLocked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if(!isTimed) {
|
||||||
|
super.waitHere();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
long wt = timeLeft0();
|
long wt = timeLeft0();
|
||||||
if(wt == 0) {
|
if(wt == 0) {
|
||||||
unlock();
|
unlock();
|
||||||
|
@ -82,30 +80,29 @@ public class Lock extends SimpleLock {
|
||||||
public synchronized void waitHere(int timeout) {
|
public synchronized void waitHere(int timeout) {
|
||||||
if(timeout == 0)
|
if(timeout == 0)
|
||||||
return;
|
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())
|
if(!super.isLocked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
do {
|
do {
|
||||||
|
long sectionOffset = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
|
if(!isTimed) {
|
||||||
|
long wt = timeout - sectionOffset;
|
||||||
|
if(wt <= 0)
|
||||||
|
return;
|
||||||
|
super.waitHere(wt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
long wt = timeLeft0();
|
long wt = timeLeft0();
|
||||||
if(wt == 0) {
|
if(wt == 0) {
|
||||||
unlock();
|
unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long sectionOffset = System.currentTimeMillis() - start;
|
|
||||||
wt = Math.min(wt, timeout - sectionOffset);
|
wt = Math.min(wt, timeout - sectionOffset);
|
||||||
if(wt == 0)
|
if(wt <= 0)
|
||||||
break;
|
return;
|
||||||
super.waitHere(wt);
|
super.waitHere(wt);
|
||||||
} while(relocking);
|
} while(relocking);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue