Skip to content

Commit

Permalink
Use the common forkjoin pool instead of a dedicated thread
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jan 13, 2024
1 parent a30c162 commit dbc1e2a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/net/citizensnpcs/api/LocationLookup.java
Expand Up @@ -6,8 +6,7 @@
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
import java.util.function.BiConsumer;

Expand All @@ -28,7 +27,6 @@
import net.citizensnpcs.api.npc.NPC;

public class LocationLookup extends BukkitRunnable {
private final ExecutorService async = Executors.newSingleThreadExecutor();
private final Map<String, PerPlayerMetadata<?>> metadata = Maps.newHashMap();
private Future<Map<UUID, PhTreeF<NPC>>> npcFuture = null;
private Map<UUID, PhTreeF<NPC>> npcWorlds = Maps.newHashMap();
Expand Down Expand Up @@ -123,7 +121,7 @@ public void run() {
uid -> Lists.newArrayList());
nodes.add(new TreeFactory.Node<>(new double[] { loc.getX(), loc.getY(), loc.getZ() }, npc));
}
npcFuture = async.submit(new TreeFactory<>(map));
npcFuture = ForkJoinPool.commonPool().submit(new TreeFactory<>(map));
}
if (playerFuture != null && playerFuture.isDone()) {
try {
Expand All @@ -145,7 +143,7 @@ public void run() {
return new TreeFactory.Node<>(new double[] { loc.getX(), loc.getY(), loc.getZ() }, p);
}));
}
playerFuture = async.submit(new TreeFactory<>(map));
playerFuture = ForkJoinPool.commonPool().submit(new TreeFactory<>(map));
}
}

Expand Down

0 comments on commit dbc1e2a

Please sign in to comment.