Skip to content

Commit

Permalink
update interval can be disabled by setting it to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
olepoeschl committed Aug 15, 2023
1 parent afad512 commit 0d0841c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/de/nqueensfaf/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public Config() {
}

public void validate() {
if (updateInterval <= 0)
throw new IllegalArgumentException("invalid value for updateInterval: only numbers >0 are allowed");
if (updateInterval < 0)
throw new IllegalArgumentException("invalid value for updateInterval: only numbers >0 or 0 (no updates) are allowed");

if (autoSaveEnabled) {
if (autoSavePercentageStep <= 0 || autoSavePercentageStep >= 100)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/nqueensfaf/Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final <T extends Solver> T solve() {
initCb.accept(this);

state = RUNNING;
if (onUpdateConsumer != null)
if (onUpdateConsumer != null && getConfig().updateInterval > 0) // if updateInterval is 0, it means, disable progress updates
executor.submit(consumeUpdates());
if (getConfig().autoSaveEnabled)
executor.submit(autoSaver());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/nqueensfaf/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public void run() {
System.out.format(progressStringFormat, loadingChars[loadingCharIdx++], progress, solutions,
getDurationPrettyString(duration));
}).onFinish(self -> {
System.out.println();
if(self.getConfig().updateInterval > 0)
System.out.println();
System.out.println("found " + self.getSolutions() + " solutions in "
+ getDurationPrettyString(self.getDuration()));
});
Expand Down

0 comments on commit 0d0841c

Please sign in to comment.