13
0
geforkt von Mirrors/Paper

Synchronized and moved Hash classes

Dieser Commit ist enthalten in:
FrozenCow 2011-03-01 19:19:50 +01:00 committet von Tahg
Ursprung 13fb0e07ce
Commit 9832ce06f1
5 geänderte Dateien mit 15 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -12,6 +12,8 @@ import java.util.Set;
import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.util.LongHashset;
import org.bukkit.craftbukkit.util.LongHashtable;
import org.bukkit.event.Event.Type;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;

Datei anzeigen

@ -8,7 +8,6 @@ import net.minecraft.server.ItemInWorldManager;
import net.minecraft.server.Packet;
import net.minecraft.server.Packet3Chat;
import net.minecraft.server.Packet6SpawnPosition;
import net.minecraft.server.Packet9Respawn;
import net.minecraft.server.ServerConfigurationManager;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;

Datei anzeigen

@ -3,13 +3,13 @@
* and open the template in the editor.
*/
package net.minecraft.server;
package org.bukkit.craftbukkit.util;
/**
*
* @author Nathan
*/
public abstract class LongHash<V> {
public abstract class LongHash {
static long toLong(int msw, int lsw) {
return ((long)msw << 32) + lsw - Integer.MIN_VALUE;
}

Datei anzeigen

@ -1,8 +1,7 @@
package net.minecraft.server;
import java.util.ArrayList;
package org.bukkit.craftbukkit.util;
import java.util.Arrays;
public class LongHashset<V> extends LongHash<V> {
public class LongHashset extends LongHash {
long values[][][] = new long[256][][];
int count = 0;

Datei anzeigen

@ -1,7 +1,9 @@
package net.minecraft.server;
package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.server.Chunk;
import net.minecraft.server.MinecraftServer;
public class LongHashtable<V> extends LongHash
{
@ -35,7 +37,7 @@ public class LongHashtable<V> extends LongHash
return value;
}
public void put(long key, V value) {
public synchronized void put(long key, V value) {
int mainIdx = (int) (key & 255);
int outerIdx = (int) ((key >> 32) & 255);
Object outer[][] = this.values[mainIdx], inner[];
@ -58,13 +60,11 @@ public class LongHashtable<V> extends LongHash
}
}
public V get(long key) {
synchronized(this) {
return containsKey(key) ? (V) cache.value : null;
}
public synchronized V get(long key) {
return containsKey(key) ? (V) cache.value : null;
}
public boolean containsKey(long key) {
public synchronized boolean containsKey(long key) {
if (cache != null && cache.key == key)
return true;
int mainIdx = (int) (key & 255);
@ -89,7 +89,7 @@ public class LongHashtable<V> extends LongHash
}
}
public void remove(long key) {
public synchronized void remove(long key) {
Object[][] outer = this.values[(int) (key & 255)];
if (outer == null) return;
@ -115,7 +115,7 @@ public class LongHashtable<V> extends LongHash
}
}
public ArrayList<V> values() {
public synchronized ArrayList<V> values() {
ArrayList<V> ret = new ArrayList<V>();
for (Object[][] outer : this.values) {
if (outer == null)