Merge branch 'CPU-noarg-annot' into 'master'
Use Lombok to reduce the constructor to an annotation. See merge request sheepitrenderfarm/client!253
This commit is contained in:
@@ -23,6 +23,7 @@ import com.sheepit.client.Log;
|
|||||||
import com.sheepit.client.os.OS;
|
import com.sheepit.client.os.OS;
|
||||||
import com.sheepit.client.os.Windows;
|
import com.sheepit.client.os.Windows;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -32,7 +33,7 @@ import java.io.InputStreamReader;
|
|||||||
/**
|
/**
|
||||||
* Provides attributes to store various characteristic about the CPU and to detect the CPU architecture and core count
|
* Provides attributes to store various characteristic about the CPU and to detect the CPU architecture and core count
|
||||||
*/
|
*/
|
||||||
@Getter @Setter public class CPU {
|
@Getter @Setter @NoArgsConstructor public class CPU {
|
||||||
public static final int MIN_CORES = Runtime.getRuntime().availableProcessors() > 1 ? 2 : 1;
|
public static final int MIN_CORES = Runtime.getRuntime().availableProcessors() > 1 ? 2 : 1;
|
||||||
private String name;
|
private String name;
|
||||||
private String model;
|
private String model;
|
||||||
@@ -40,16 +41,10 @@ import java.io.InputStreamReader;
|
|||||||
/**
|
/**
|
||||||
* The detail is limited to only if it's 32 or 64bit
|
* The detail is limited to only if it's 32 or 64bit
|
||||||
*/
|
*/
|
||||||
private String arch; // 32 or 64 bits
|
private final String arch = detectArch();
|
||||||
private static final Log log = Log.getInstance(null);
|
private static final Log log = Log.getInstance(null);
|
||||||
private static Integer logicalCores = -1; // Store core count throughout instances
|
private static Integer logicalCores = -1; // Store core count throughout instances
|
||||||
|
|
||||||
public CPU() {
|
|
||||||
this.name = null;
|
|
||||||
this.model = null;
|
|
||||||
this.family = null;
|
|
||||||
this.generateArch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of processors available.
|
* Returns the maximum number of processors available.
|
||||||
@@ -122,23 +117,20 @@ import java.io.InputStreamReader;
|
|||||||
/**
|
/**
|
||||||
* Detects whether the CPU is currently operating in 32 or 64 bit mode
|
* Detects whether the CPU is currently operating in 32 or 64 bit mode
|
||||||
*/
|
*/
|
||||||
public void generateArch() {
|
private static String detectArch() {
|
||||||
String arch = System.getProperty("os.arch").toLowerCase();
|
String arch = System.getProperty("os.arch").toLowerCase();
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case "i386":
|
case "i386":
|
||||||
case "i686":
|
case "i686":
|
||||||
case "x86":
|
case "x86":
|
||||||
this.arch = "32bit";
|
return "32bit";
|
||||||
break;
|
|
||||||
case "amd64":
|
case "amd64":
|
||||||
case "x86_64":
|
case "x86_64":
|
||||||
case "x64":
|
case "x64":
|
||||||
case "aarch64":
|
case "aarch64":
|
||||||
this.arch = "64bit";
|
return "64bit";
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
this.arch = null;
|
return null;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user