mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-15 23:26:33 +01:00
Use blocking queue
This commit is contained in:
parent
d2128ab045
commit
f8e1bb0b71
@ -1,6 +1,6 @@
|
||||
name: FastAsyncWorldEdit
|
||||
main: com.boydti.fawe.bukkit.FaweBukkit
|
||||
version: 3.3.14
|
||||
version: 3.3.15
|
||||
description: Fast Async WorldEdit plugin
|
||||
authors: [Empire92]
|
||||
loadbefore: [WorldEdit]
|
||||
|
@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@ -25,7 +26,7 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
* Map of chunks in the queue
|
||||
*/
|
||||
private ConcurrentHashMap<Long, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
||||
private ArrayDeque<FaweChunk<Chunk>> chunks = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<FaweChunk<Chunk>> chunks = new LinkedBlockingDeque<>();
|
||||
|
||||
public BukkitQueue_0(String world) {
|
||||
super(world);
|
||||
@ -142,7 +143,7 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
return chunks.size();
|
||||
}
|
||||
|
||||
private ArrayDeque<FaweChunk<Chunk>> toUpdate = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<FaweChunk<Chunk>> toUpdate = new LinkedBlockingDeque<>();
|
||||
|
||||
public boolean execute(FaweChunk<Chunk> fc) {
|
||||
if (fc == null) {
|
||||
|
@ -30,6 +30,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -116,7 +117,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private ArrayDeque<IntegerPair> loadQueue = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(int x, int y, int z) {
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -109,7 +110,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private ArrayDeque<IntegerPair> loadQueue = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(int x, int y, int z) {
|
||||
|
@ -3,9 +3,9 @@ package com.boydti.fawe.util;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
public class SetQueue {
|
||||
|
||||
@ -14,8 +14,8 @@ public class SetQueue {
|
||||
*/
|
||||
public static final SetQueue IMP = new SetQueue();
|
||||
|
||||
public final ArrayDeque<FaweQueue> activeQueues;
|
||||
public final ArrayDeque<FaweQueue> inactiveQueues;
|
||||
public final LinkedBlockingDeque<FaweQueue> activeQueues;
|
||||
public final LinkedBlockingDeque<FaweQueue> inactiveQueues;
|
||||
|
||||
/**
|
||||
* Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the server
|
||||
@ -27,12 +27,12 @@ public class SetQueue {
|
||||
/**
|
||||
* A queue of tasks that will run when the queue is empty
|
||||
*/
|
||||
private final ArrayDeque<Runnable> runnables = new ArrayDeque<>();
|
||||
private final LinkedBlockingDeque<Runnable> runnables = new LinkedBlockingDeque<>();
|
||||
|
||||
|
||||
public SetQueue() {
|
||||
activeQueues = new ArrayDeque();
|
||||
inactiveQueues = new ArrayDeque<>();
|
||||
activeQueues = new LinkedBlockingDeque();
|
||||
inactiveQueues = new LinkedBlockingDeque<>();
|
||||
TaskManager.IMP.repeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -156,7 +156,7 @@ public class SetQueue {
|
||||
if (this.runnables.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
final ArrayDeque<Runnable> tmp = this.runnables.clone();
|
||||
final LinkedBlockingDeque<Runnable> tmp = new LinkedBlockingDeque<>(this.runnables);
|
||||
this.runnables.clear();
|
||||
for (final Runnable runnable : tmp) {
|
||||
runnable.run();
|
||||
|
@ -3,9 +3,9 @@ package com.boydti.fawe.forge.v0;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.util.FaweQueue;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -19,7 +19,7 @@ public abstract class SpongeQueue_0 extends FaweQueue {
|
||||
* Map of chunks in the queue
|
||||
*/
|
||||
private final ConcurrentHashMap<Long, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
||||
private ArrayDeque<FaweChunk<Chunk>> chunks = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<FaweChunk<Chunk>> chunks = new LinkedBlockingDeque<>();
|
||||
|
||||
public SpongeQueue_0(String world) {
|
||||
super(world);
|
||||
@ -113,7 +113,7 @@ public abstract class SpongeQueue_0 extends FaweQueue {
|
||||
return chunks.size();
|
||||
}
|
||||
|
||||
private final ArrayDeque<FaweChunk<Chunk>> toUpdate = new ArrayDeque<>();
|
||||
private final LinkedBlockingDeque<FaweChunk<Chunk>> toUpdate = new LinkedBlockingDeque<>();
|
||||
|
||||
public boolean execute(final FaweChunk<Chunk> fc) {
|
||||
if (fc == null) {
|
||||
|
@ -11,13 +11,13 @@ import com.boydti.fawe.object.PseudoRandom;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@ -60,7 +60,7 @@ public class SpongeQueue_1_8 extends SpongeQueue_0 {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private ArrayDeque<IntegerPair> loadQueue = new ArrayDeque<>();
|
||||
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(int x, int y, int z) {
|
||||
|
Loading…
Reference in New Issue
Block a user