Add ui for process priority

This commit is contained in:
Rolf Aretz Lap
2017-03-19 17:38:22 +01:00
committed by Laurent Clouet
parent e7354499ad
commit d4db1670a1
3 changed files with 41 additions and 4 deletions

View File

@@ -50,6 +50,7 @@ public class SettingsLoader {
private String autoSignIn;
private String ui;
private String tileSize;
private int priority;
public SettingsLoader() {
path = getDefaultFilePath();
@@ -59,7 +60,7 @@ public class SettingsLoader {
path = path_;
}
public SettingsLoader(String login_, String password_, String proxy_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_) {
public SettingsLoader(String login_, String password_, String proxy_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
path = getDefaultFilePath();
login = login_;
password = password_;
@@ -68,6 +69,7 @@ public class SettingsLoader {
autoSignIn = String.valueOf(autoSignIn_);
ui = ui_;
tileSize = tileSize_;
priority = priority_;
if (cores_ > 0) {
cores = String.valueOf(cores_);
}
@@ -98,6 +100,7 @@ public class SettingsLoader {
OutputStream output = null;
try {
output = new FileOutputStream(path);
prop.setProperty("priority", new Integer(priority).toString());
if (cacheDir != null) {
prop.setProperty("cache-dir", cacheDir);
@@ -181,6 +184,7 @@ public class SettingsLoader {
this.autoSignIn = null;
this.ui = null;
this.tileSize = null;
this.priority = 19; // must be the same default as Configuration
if (new File(path).exists() == false) {
return;
@@ -231,6 +235,10 @@ public class SettingsLoader {
if (prop.containsKey("tile-size")) {
this.tileSize = prop.getProperty("tile-size");
}
if (prop.containsKey("priority")) {
this.priority = Integer.parseInt(prop.getProperty("priority"));
}
}
catch (IOException io) {
io.printStackTrace();
@@ -269,6 +277,9 @@ public class SettingsLoader {
config.setProxy(proxy);
}
if (config.getPriority() == 19) { // 19 is default value
config.setUsePriority(priority);
}
try {
if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType.valueOf(computeMethod))) {
config.setComputeMethod(ComputeType.valueOf(computeMethod));
@@ -304,6 +315,6 @@ public class SettingsLoader {
@Override
public String toString() {
return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + ", cacheDir=" + cacheDir + "]";
return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + ", cacheDir=" + cacheDir + "priority="+priority+"]";
}
}