mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-18 00:19:32 -08:00
Add a setting to the timeout delay.
This commit is contained in:
parent
40bdbd1948
commit
b8f8c4486a
|
@ -30,6 +30,10 @@ public class Configuration {
|
||||||
*/
|
*/
|
||||||
private static final TomlWriter TOML_WRITER = new TomlWriter();
|
private static final TomlWriter TOML_WRITER = new TomlWriter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The computation delay for which the thread can run without interruption.
|
||||||
|
*/
|
||||||
|
private double computationDelay = 0;
|
||||||
/**
|
/**
|
||||||
* The implementation of the number that should be used.
|
* The implementation of the number that should be used.
|
||||||
*/
|
*/
|
||||||
|
@ -51,10 +55,12 @@ public class Configuration {
|
||||||
/**
|
/**
|
||||||
* Creates a new configuration with the given values.
|
* Creates a new configuration with the given values.
|
||||||
*
|
*
|
||||||
|
* @param computationDelay the delay before the computation gets killed.
|
||||||
* @param numberImplementation the number implementation, like "naive" or "precise"
|
* @param numberImplementation the number implementation, like "naive" or "precise"
|
||||||
* @param disabledPlugins the list of disabled plugins.
|
* @param disabledPlugins the list of disabled plugins.
|
||||||
*/
|
*/
|
||||||
public Configuration(String numberImplementation, String[] disabledPlugins) {
|
public Configuration(double computationDelay, String numberImplementation, String[] disabledPlugins) {
|
||||||
|
this.computationDelay = computationDelay;
|
||||||
this.numberImplementation = numberImplementation;
|
this.numberImplementation = numberImplementation;
|
||||||
this.disabledPlugins.addAll(Arrays.asList(disabledPlugins));
|
this.disabledPlugins.addAll(Arrays.asList(disabledPlugins));
|
||||||
}
|
}
|
||||||
|
@ -75,6 +81,7 @@ public class Configuration {
|
||||||
* @param otherConfiguration the configuration to copy from.
|
* @param otherConfiguration the configuration to copy from.
|
||||||
*/
|
*/
|
||||||
public void copyFrom(Configuration otherConfiguration) {
|
public void copyFrom(Configuration otherConfiguration) {
|
||||||
|
this.computationDelay = otherConfiguration.computationDelay;
|
||||||
this.numberImplementation = otherConfiguration.numberImplementation;
|
this.numberImplementation = otherConfiguration.numberImplementation;
|
||||||
this.disabledPlugins.addAll(otherConfiguration.disabledPlugins);
|
this.disabledPlugins.addAll(otherConfiguration.disabledPlugins);
|
||||||
}
|
}
|
||||||
|
@ -130,4 +137,23 @@ public class Configuration {
|
||||||
return disabledPlugins;
|
return disabledPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the computation delay specified in the configuration.
|
||||||
|
*
|
||||||
|
* @return the computaton delay.
|
||||||
|
*/
|
||||||
|
public double getComputationDelay() {
|
||||||
|
return computationDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the computation delay.
|
||||||
|
*
|
||||||
|
* @param computationDelay the new computation delay.
|
||||||
|
*/
|
||||||
|
public void setComputationDelay(double computationDelay) {
|
||||||
|
this.computationDelay = computationDelay;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,9 @@ public class AbacusController implements PluginListener {
|
||||||
*/
|
*/
|
||||||
private final Runnable TIMER_RUNNABLE = () -> {
|
private final Runnable TIMER_RUNNABLE = () -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(30 * 1000);
|
Configuration abacusConfig = abacus.getConfiguration();
|
||||||
|
if(abacusConfig.getComputationDelay() != 0)
|
||||||
|
Thread.sleep((long) (abacusConfig.getComputationDelay() * 1000));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user