the things are no longer unthingful
All checks were successful
/ Build & Publish (push) Successful in 1m25s
All checks were successful
/ Build & Publish (push) Successful in 1m25s
This commit is contained in:
parent
30efcd968d
commit
225753b31a
3 changed files with 13 additions and 4 deletions
|
|
@ -43,6 +43,7 @@ public class TimedLock extends UntimedLock implements Timed {
|
|||
if (super.isLocked()) {
|
||||
super.unlock();
|
||||
}
|
||||
|
||||
super.lock();
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +109,7 @@ public class TimedLock extends UntimedLock implements Timed {
|
|||
@Override
|
||||
public void waitHere() {
|
||||
while (isLocked()) {
|
||||
TimerDuration t = timer.timeLeft();
|
||||
super.waitHere(t);
|
||||
super.waitHere(timer.timeLeft());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,8 @@ public class TimedLock extends UntimedLock implements Timed {
|
|||
public void waitHere(TimerDuration timeout) {
|
||||
Timer localTimer = new Timer(timeout);
|
||||
while (isLocked() && !localTimer.hasElapsed()) {
|
||||
super.waitHere(localTimer.timeLeft().min(timer.timeLeft()));
|
||||
TimerDuration duration = localTimer.timeLeft().min(timer.timeLeft());
|
||||
super.waitHere(duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package de.tudbut.tudbutil.locks;
|
||||
|
||||
import de.tudbut.tudbutil.timing.TimePoint;
|
||||
import de.tudbut.tudbutil.timing.Timer;
|
||||
import de.tudbut.tudbutil.timing.TimerDuration;
|
||||
|
||||
|
|
@ -57,6 +56,10 @@ public class UntimedLock implements Lock {
|
|||
synchronized (condvar) {
|
||||
condvar.notifyAll();
|
||||
}
|
||||
|
||||
while (waiting.get() > 0) {
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,4 +102,9 @@ public class TimerDuration {
|
|||
|
||||
return of(millis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TimerDuration/" + type + "(" + millis + ')';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue