This commit is contained in:
Daniel Mills
2021-08-10 06:06:39 -04:00
parent fc4377abaf
commit d0fb3dde66
2 changed files with 31 additions and 12 deletions

View File

@@ -33,6 +33,7 @@ import java.util.function.Supplier;
public class HyperLock {
private final ConcurrentLinkedHashMap<Long, ReentrantLock> locks;
private final BiFunction<? super Long, ? super ReentrantLock, ? extends ReentrantLock> accessor;
private boolean enabled = true;
public HyperLock() {
this(1024, false);
@@ -120,10 +121,24 @@ public class HyperLock {
}
public void lock(int x, int z) {
if(!enabled)
{
return;
}
getLock(x, z).lock();
}
public void unlock(int x, int z) {
if(!enabled)
{
return;
}
getLock(x, z).unlock();
}
public void disable() {
enabled = false;
}
}