mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Locks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user