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.Windows;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
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
|
||||
*/
|
||||
@Getter @Setter public class CPU {
|
||||
@Getter @Setter @NoArgsConstructor public class CPU {
|
||||
public static final int MIN_CORES = Runtime.getRuntime().availableProcessors() > 1 ? 2 : 1;
|
||||
private String name;
|
||||
private String model;
|
||||
@@ -40,16 +41,10 @@ import java.io.InputStreamReader;
|
||||
/**
|
||||
* 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 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.
|
||||
@@ -122,23 +117,20 @@ import java.io.InputStreamReader;
|
||||
/**
|
||||
* 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();
|
||||
switch (arch) {
|
||||
case "i386":
|
||||
case "i686":
|
||||
case "x86":
|
||||
this.arch = "32bit";
|
||||
break;
|
||||
return "32bit";
|
||||
case "amd64":
|
||||
case "x86_64":
|
||||
case "x64":
|
||||
case "aarch64":
|
||||
this.arch = "64bit";
|
||||
break;
|
||||
return "64bit";
|
||||
default:
|
||||
this.arch = null;
|
||||
break;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user