mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-23 17:19:16 +00:00
fix hyperlock not releasing on exceptions
This commit is contained in:
@@ -59,14 +59,21 @@ public class HyperLock {
|
|||||||
|
|
||||||
public void with(int x, int z, Runnable r) {
|
public void with(int x, int z, Runnable r) {
|
||||||
lock(x, z);
|
lock(x, z);
|
||||||
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
|
} finally {
|
||||||
unlock(x, z);
|
unlock(x, z);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void withLong(long k, Runnable r) {
|
public void withLong(long k, Runnable r) {
|
||||||
lock(Cache.keyX(k), Cache.keyZ(k));
|
int x = Cache.keyX(k), z = Cache.keyZ(k);
|
||||||
|
lock(x, z);
|
||||||
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
unlock(Cache.keyX(k), Cache.keyZ(k));
|
} finally {
|
||||||
|
unlock(x, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withNasty(int x, int z, NastyRunnable r) throws Throwable {
|
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) {
|
public <T> T withResult(int x, int z, Supplier<T> r) {
|
||||||
lock(x, z);
|
lock(x, z);
|
||||||
T t = r.get();
|
try {
|
||||||
|
return r.get();
|
||||||
|
} finally {
|
||||||
unlock(x, z);
|
unlock(x, z);
|
||||||
return t;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T withNastyResult(int x, int z, NastySupplier<T> r) throws Throwable {
|
public <T> T withNastyResult(int x, int z, NastySupplier<T> r) throws Throwable {
|
||||||
|
|||||||
Reference in New Issue
Block a user