Remove monitored locks with default fairness, use basic version

This commit is contained in:
P0nk
2022-08-11 14:26:23 +02:00
parent 8657b765b1
commit 54878ebe8c
9 changed files with 25 additions and 57 deletions

View File

@@ -26,10 +26,6 @@ import net.server.audit.locks.active.TrackerReentrantLock;
* @author RonanLana
*/
public class MonitoredReentrantLockFactory {
public static TrackerReentrantLock createLock(MonitoredLockType id) {
return new TrackerReentrantLock(id);
}
public static TrackerReentrantLock createLock(MonitoredLockType id, boolean fair) {
return new TrackerReentrantLock(id, fair);
}

View File

@@ -1,7 +1,5 @@
package net.server.coordinator.session;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -10,6 +8,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Manages session initialization using remote host (ip address).
@@ -24,7 +23,7 @@ public class SessionInitialization {
SessionInitialization() {
for (int i = 0; i < 100; i++) {
locks.add(MonitoredReentrantLockFactory.createLock(MonitoredLockType.SERVER_LOGIN_COORD));
locks.add(new ReentrantLock());
}
}

View File

@@ -22,7 +22,6 @@ package net.server.coordinator.world;
import client.Character;
import config.YamlConfig;
import net.server.Server;
import net.server.audit.LockCollector;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReentrantLock;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
@@ -34,13 +33,14 @@ import tools.Pair;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author Ronan
*/
public class MonsterAggroCoordinator {
private MonitoredReentrantLock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_AGGRO);
private final Lock lock = new ReentrantLock();
private final MonitoredReentrantLock idleLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_AGGRO_IDLE, true);
private long lastStopTime = Server.getInstance().getCurrentTime();
@@ -375,15 +375,5 @@ public class MonsterAggroCoordinator {
} finally {
lock.unlock();
}
disposeLocks();
}
private void disposeLocks() {
LockCollector.getInstance().registerDisposeAction(() -> emptyLocks());
}
private void emptyLocks() {
lock = lock.dispose();
}
}