Threadsafe EntityTracker w/ cleanup
This commit is contained in:
@@ -7,6 +7,9 @@ import com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -14,6 +17,7 @@ import org.apache.logging.log4j.Logger;
|
||||
* Akarin Changes Note
|
||||
* 1) Made collections and entry access thread-safe (safety issue)
|
||||
*/
|
||||
@ThreadSafe // Akarin
|
||||
public class EntityTracker {
|
||||
|
||||
private static final Logger a = LogManager.getLogger();
|
||||
@@ -21,7 +25,7 @@ public class EntityTracker {
|
||||
private final Set<EntityTrackerEntry> c = Sets.newHashSet();
|
||||
public final ReentrantReadWriteUpdateLock entriesLock = new ReentrantReadWriteUpdateLock(); // Akarin - add lock
|
||||
public final IntHashMap<EntityTrackerEntry> trackedEntities = new IntHashMap();
|
||||
private int e;
|
||||
private volatile int e; // Akarin - volatile
|
||||
|
||||
public EntityTracker(WorldServer worldserver) {
|
||||
this.world = worldserver;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EntityTrackerEntry {
|
||||
private static final Logger c = LogManager.getLogger();
|
||||
private final Entity tracker;
|
||||
private final int e;
|
||||
private volatile int f; // Akarin
|
||||
private volatile int f; // Akarin - volatile
|
||||
private final int g;
|
||||
private long xLoc;
|
||||
private long yLoc;
|
||||
|
||||
@@ -503,12 +503,12 @@ public class PlayerChunkMap {
|
||||
}
|
||||
|
||||
public synchronized void a(PlayerChunk playerchunk) { // Akarin - synchronized
|
||||
org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Add"); // Paper // Akarin
|
||||
// org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Add"); // Paper // Akarin
|
||||
this.f.add(playerchunk);
|
||||
}
|
||||
|
||||
public synchronized void b(PlayerChunk playerchunk) { // Akarin - synchronized
|
||||
// org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Remove"); // Paper // Akarin
|
||||
org.spigotmc.AsyncCatcher.catchOp("Async Player Chunk Remove"); // Paper
|
||||
ChunkCoordIntPair chunkcoordintpair = playerchunk.a();
|
||||
long i = d(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user