mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 08:58:20 +01:00
Thread count should depend on the processor count
This commit is contained in:
parent
15b116a770
commit
dba368d16f
@ -8,7 +8,6 @@ import net.minestom.server.lock.Acquisition;
|
|||||||
import net.minestom.server.monitoring.TickMonitor;
|
import net.minestom.server.monitoring.TickMonitor;
|
||||||
import net.minestom.server.network.ConnectionManager;
|
import net.minestom.server.network.ConnectionManager;
|
||||||
import net.minestom.server.network.player.NettyPlayerConnection;
|
import net.minestom.server.network.player.NettyPlayerConnection;
|
||||||
import net.minestom.server.thread.PerChunkThreadProvider;
|
|
||||||
import net.minestom.server.thread.PerInstanceThreadProvider;
|
import net.minestom.server.thread.PerInstanceThreadProvider;
|
||||||
import net.minestom.server.thread.ThreadProvider;
|
import net.minestom.server.thread.ThreadProvider;
|
||||||
import net.minestom.server.utils.async.AsyncUtils;
|
import net.minestom.server.utils.async.AsyncUtils;
|
||||||
@ -40,8 +39,8 @@ public final class UpdateManager {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// DEFAULT THREAD PROVIDER
|
// DEFAULT THREAD PROVIDER
|
||||||
threadProvider = new PerInstanceThreadProvider(4);
|
threadProvider = new PerInstanceThreadProvider();
|
||||||
//threadProvider = new PerChunkThreadProvider(4);
|
//threadProvider = new PerChunkThreadProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,10 @@ public class PerChunkThreadProvider extends ThreadProvider {
|
|||||||
super(threadCount);
|
super(threadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PerChunkThreadProvider() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long findThread(@NotNull Chunk chunk) {
|
public long findThread(@NotNull Chunk chunk) {
|
||||||
return chunk.hashCode();
|
return chunk.hashCode();
|
||||||
|
@ -13,6 +13,10 @@ public class PerInstanceThreadProvider extends ThreadProvider {
|
|||||||
super(threadCount);
|
super(threadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PerInstanceThreadProvider() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long findThread(@NotNull Chunk chunk) {
|
public long findThread(@NotNull Chunk chunk) {
|
||||||
return chunk.getInstance().hashCode();
|
return chunk.getInstance().hashCode();
|
||||||
|
@ -51,6 +51,10 @@ public abstract class ThreadProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ThreadProvider() {
|
||||||
|
this(Runtime.getRuntime().availableProcessors());
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void onInstanceCreate(@NotNull Instance instance) {
|
public synchronized void onInstanceCreate(@NotNull Instance instance) {
|
||||||
instance.getChunks().forEach(this::addChunk);
|
instance.getChunks().forEach(this::addChunk);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user