make relocking with different modes work
All checks were successful
/ Build & Publish (push) Successful in 44s

This commit is contained in:
Daniella 2024-06-25 05:31:37 +02:00
parent 8fd30ea15d
commit 28dfebea25
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -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);
}