Skip to content

Commit

Permalink
Make thread count configurable (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrek0429 authored Apr 5, 2024
1 parent 83665d4 commit d183c66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ How many scroll pixels (as reported by L.DomEvent.getWheelDelta) mean
for security reasons. But you do you, boo boo.""")
public static boolean HTTPD_FOLLOW_SYMLINKS = false;

@Key("settings.performance.live-update-threads")
@Comment("""
The number of process-threads to use for real-time marker updates on the map.
Value of -1 will use 50% of the available cpu-threads. (recommended)""")
public static int LIVE_UPDATE_THREADS = -1;

@Key("settings.performance.render-threads")
@Comment("""
The number of process-threads to use for loading and scanning chunks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class UpdateLiveData extends AbstractDataTask {
.build();
private Map<String, CompletableFuture<Void>> liveUpdateFutures;

public UpdateLiveData(@NotNull World world) {
super(1, true, world, "Pl3xMap-LiveData", 2);
public UpdateLiveData(@NotNull World world, int threads) {
super(1, true, world, "Pl3xMap-LiveData", threads);
this.liveUpdateFutures = new HashMap<>();
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/net/pl3x/map/core/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javax.imageio.ImageIO;
import net.pl3x.map.core.Keyed;
import net.pl3x.map.core.Pl3xMap;
import net.pl3x.map.core.configuration.Config;
import net.pl3x.map.core.configuration.PlayersLayerConfig;
import net.pl3x.map.core.configuration.SpawnLayerConfig;
import net.pl3x.map.core.configuration.WorldBorderLayerConfig;
Expand Down Expand Up @@ -128,7 +129,7 @@ public World(@NotNull String name, long seed, @NotNull Point spawn, @NotNull Typ
this.regionModifiedState = new RegionModifiedState(this);
//this.regionFileWatcher = new RegionFileWatcher(this);
this.markerTask = new UpdateMarkerData(this);
this.liveDataTask = new UpdateLiveData(this);
this.liveDataTask = new UpdateLiveData(this, Config.LIVE_UPDATE_THREADS);
}

protected void init() {
Expand Down

0 comments on commit d183c66

Please sign in to comment.