9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

fix hyperlock not releasing on exceptions

This commit is contained in:
Julian Krings
2025-09-04 13:55:03 +02:00
parent 9e147774bd
commit 79088c0305

View File

@@ -59,14 +59,21 @@ public class HyperLock {
public void with(int x, int z, Runnable r) {
lock(x, z);
r.run();
unlock(x, z);
try {
r.run();
} finally {
unlock(x, z);
}
}
public void withLong(long k, Runnable r) {
lock(Cache.keyX(k), Cache.keyZ(k));
r.run();
unlock(Cache.keyX(k), Cache.keyZ(k));
int x = Cache.keyX(k), z = Cache.keyZ(k);
lock(x, z);
try {
r.run();
} finally {
unlock(x, z);
}
}
public void withNasty(int x, int z, NastyRunnable r) throws Throwable {
@@ -103,9 +110,11 @@ public class HyperLock {
public <T> T withResult(int x, int z, Supplier<T> r) {
lock(x, z);
T t = r.get();
unlock(x, z);
return t;
try {
return r.get();
} finally {
unlock(x, z);
}
}
public <T> T withNastyResult(int x, int z, NastySupplier<T> r) throws Throwable {