Skip to content

Commit 1ddf5ba

Browse files
committed
After consideration, it is more appropriate to rename the "Daemon Thread" to "Core Thread".
1 parent 8784907 commit 1ddf5ba

File tree

12 files changed

+87
-117
lines changed

12 files changed

+87
-117
lines changed

src/main/java/hellfirepvp/modularmachinery/client/gui/GuiFactoryController.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ private void drawRecipeQueue() {
7171
int offsetY = RECIPE_QUEUE_OFFSET_Y;
7272
int currentScroll = scrollbar.getCurrentScroll();
7373

74-
Collection<RecipeThread> daemonThreads = factory.getDaemonRecipeThreads().values();
74+
Collection<RecipeThread> coreThreadList = factory.getCoreRecipeThreads().values();
7575
List<RecipeThread> threads = factory.getRecipeThreadList();
76-
List<RecipeThread> recipeThreadList = new ArrayList<>((int) ((daemonThreads.size() + threads.size()) * 1.5));
77-
recipeThreadList.addAll(daemonThreads);
76+
List<RecipeThread> recipeThreadList = new ArrayList<>((int) ((coreThreadList.size() + threads.size()) * 1.5));
77+
recipeThreadList.addAll(coreThreadList);
7878
recipeThreadList.addAll(threads);
7979

8080
for (int i = 0; i < Math.min(MAX_PAGE_ELEMENTS, recipeThreadList.size()); i++) {
@@ -90,8 +90,8 @@ private void drawRecipeInfo(RecipeThread thread, int id, int offsetY) {
9090

9191
this.mc.getTextureManager().bindTexture(TEXTURES_FACTORY_ELEMENTS);
9292

93-
// Daemon Thread Color
94-
if (thread.isDaemon()) {
93+
// Core Thread Color
94+
if (thread.isCoreThread()) {
9595
GlStateManager.color(0.7F, 0.9F, 1.0F, 1.0F);
9696
} else {
9797
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
@@ -128,7 +128,7 @@ private void drawRecipeStatus(RecipeThread thread, int id, int y) {
128128
int parallelism = activeRecipe == null ? 1 : activeRecipe.getParallelism();
129129

130130
String threadName;
131-
if (thread.isDaemon()) {
131+
if (thread.isCoreThread()) {
132132
String name = thread.getThreadName();
133133
threadName = I18n.hasKey(name) ? I18n.format(name) : name;
134134
} else {
@@ -202,7 +202,7 @@ private void drawFactoryStatus() {
202202
offsetY = drawParallelismInfo(offsetX, offsetY, fr);
203203

204204
offsetY += 5;
205-
fr.drawStringWithShadow(String.format("%sμs/t", TileMultiblockMachineController.performanceCache), offsetX, offsetY, 0xFFFFFF);
205+
fr.drawStringWithShadow(String.format("Avg: %sμs/t", TileMultiblockMachineController.performanceCache), offsetX, offsetY, 0xFFFFFF);
206206

207207
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
208208
GlStateManager.popMatrix();
@@ -330,9 +330,9 @@ public void handleMouseInput() throws IOException {
330330
private void updateScrollbar(int displayX, int displayY) {
331331
scrollbar.setLeft(SCROLLBAR_LEFT + displayX).setTop(SCROLLBAR_TOP + displayY).setHeight(SCROLLBAR_HEIGHT);
332332

333-
Map<String, RecipeThread> daemonRecipeThreads = factory.getDaemonRecipeThreads();
334-
List<RecipeThread> recipeThreadList = factory.getRecipeThreadList();
335-
scrollbar.setRange(0, Math.max(0, daemonRecipeThreads.size() + recipeThreadList.size() - MAX_PAGE_ELEMENTS), 1);
333+
Map<String, RecipeThread> coreThreads = factory.getCoreRecipeThreads();
334+
List<RecipeThread> threadList = factory.getRecipeThreadList();
335+
scrollbar.setRange(0, Math.max(0, coreThreads.size() + threadList.size() - MAX_PAGE_ELEMENTS), 1);
336336
}
337337

338338
@Override

src/main/java/hellfirepvp/modularmachinery/client/gui/GuiMachineController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
163163
}
164164
}
165165

166-
fr.drawStringWithShadow(String.format("%sμs/t", TileMultiblockMachineController.performanceCache), offsetX, offsetY, 0xFFFFFF);
166+
fr.drawStringWithShadow(String.format("Avg: %sμs/t", TileMultiblockMachineController.performanceCache), offsetX, offsetY, 0xFFFFFF);
167167

168168
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
169169
GlStateManager.popMatrix();

src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/MachineBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ public MachineBuilder setMaxThreads(int maxThreads) {
469469
}
470470

471471
@ZenMethod
472-
public MachineBuilder addDaemonThread(RecipeThread thread) {
473-
this.machine.addDaemonRecipeThread(thread);
472+
public MachineBuilder addCoreThread(RecipeThread thread) {
473+
this.machine.addCoreThread(thread);
474474
return this;
475475
}
476476

src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/MachineModifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void setMaxParallelism(String machineName, int maxParallelism) {
5353

5454
@ZenMethod
5555
public static void setMaxThreads(String machineName, int maxThreads) {
56-
// Maybe the author only wanted to use the daemon thread?
56+
// Maybe the author only wanted to use the core thread?
5757
if (maxThreads < 0) {
5858
CraftTweakerAPI.logError("Max Threads must larger than 0!");
5959
}
@@ -68,14 +68,14 @@ public static void setMaxThreads(String machineName, int maxThreads) {
6868
}
6969

7070
@ZenMethod
71-
public static void addDaemonThread(String machineName, RecipeThread thread) {
71+
public static void addCoreThread(String machineName, RecipeThread thread) {
7272
WAIT_FOR_MODIFY.add(() -> {
7373
DynamicMachine machine = MachineRegistry.getRegistry().getMachine(new ResourceLocation(ModularMachinery.MODID, machineName));
7474
if (machine == null) {
7575
CraftTweakerAPI.logError("Could not find machine `" + machineName + "`!");
7676
return;
7777
}
78-
machine.addDaemonRecipeThread(thread);
78+
machine.addCoreThread(thread);
7979
});
8080
}
8181

src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/RecipePrimer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public RecipePrimer setSingleThread(boolean singleThread) {
195195
}
196196

197197
/**
198-
* 设置此配方只能被指定的守护线程执行
198+
* 设置此配方只能被指定的核心线程执行
199199
* @param name 线程名
200200
*/
201201
@ZenMethod

src/main/java/hellfirepvp/modularmachinery/common/integration/theoneprobe/MMInfoProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ private static void processFactoryControllerTOP(TileFactoryController factory, I
9595
}
9696

9797
AtomicInteger i = new AtomicInteger();
98-
Collection<RecipeThread> daemonThreads = factory.getDaemonRecipeThreads().values();
99-
List<RecipeThread> recipeThreadList = new ArrayList<>((int) ((daemonThreads.size() + recipeThreads.size()) * 1.5));
100-
recipeThreadList.addAll(daemonThreads);
98+
Collection<RecipeThread> coreThreadList = factory.getCoreRecipeThreads().values();
99+
List<RecipeThread> recipeThreadList = new ArrayList<>((int) ((coreThreadList.size() + recipeThreads.size()) * 1.5));
100+
recipeThreadList.addAll(coreThreadList);
101101
recipeThreadList.addAll(recipeThreads);
102102

103103
recipeThreadList.stream().limit(6).forEach(thread -> {
@@ -109,7 +109,7 @@ private static void processFactoryControllerTOP(TileFactoryController factory, I
109109
int progressBarBorderColor = ModIntegrationTOP.recipeProgressBarBorderColor;
110110

111111
String threadName;
112-
if (thread.isDaemon()) {
112+
if (thread.isCoreThread()) {
113113
threadName = TextFormatting.BLUE + "{*" + thread.getThreadName() + "*}";
114114
i.getAndIncrement();
115115
} else {

src/main/java/hellfirepvp/modularmachinery/common/machine/DynamicMachine.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ public class DynamicMachine extends AbstractMachine {
5050
private final Map<String, SmartInterfaceType> smartInterfaces = new HashMap<>();
5151
private final List<MultiBlockModifierReplacement> multiBlockModifiers = new ArrayList<>();
5252
private final TaggedPositionBlockArray pattern = new TaggedPositionBlockArray();
53-
private final Map<String, RecipeThread> daemonThreads = new LinkedHashMap<>();
53+
private final Map<String, RecipeThread> coreThreadPreset = new LinkedHashMap<>();
5454

5555
public DynamicMachine(String registryName) {
5656
super(registryName);
5757
}
5858

59-
public void addDaemonRecipeThread(RecipeThread thread) {
60-
daemonThreads.put(thread.getThreadName(), thread);
59+
public void addCoreThread(RecipeThread thread) {
60+
coreThreadPreset.put(thread.getThreadName(), thread);
6161
}
6262

63-
public Map<String, RecipeThread> getDaemonThreads() {
64-
return daemonThreads;
63+
public Map<String, RecipeThread> getCoreThreadPreset() {
64+
return coreThreadPreset;
6565
}
6666

6767
public boolean hasSmartInterfaceType(String type) {

src/main/java/hellfirepvp/modularmachinery/common/machine/factory/RecipeThread.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class RecipeThread {
4242
private final Map<String, RecipeModifier> semiPermanentModifiers = new HashMap<>();
4343
public int idleTime = 0;
4444
private TileFactoryController factory;
45-
private boolean isDaemon;
45+
private boolean isCoreThread;
4646
private String threadName;
4747
private FactoryRecipeSearchTask searchTask;
4848
private ActiveMachineRecipe activeRecipe = null;
@@ -56,19 +56,19 @@ public RecipeThread(TileFactoryController factory) {
5656

5757
public RecipeThread(
5858
TileFactoryController factory,
59-
boolean isDaemon,
59+
boolean isCoreThread,
6060
String threadName,
6161
Set<MachineRecipe> recipeSet,
6262
Map<String, RecipeModifier> permanentModifiers) {
6363
this.factory = factory;
64-
this.isDaemon = isDaemon;
64+
this.isCoreThread = isCoreThread;
6565
this.threadName = threadName;
6666
this.recipeSet.addAll(recipeSet);
6767
this.permanentModifiers.putAll(permanentModifiers);
6868
}
6969

7070
@ZenMethod
71-
public static RecipeThread createDaemonThread(String threadName) {
71+
public static RecipeThread createCoreThread(String threadName) {
7272
return new RecipeThread(null, true, threadName, Collections.emptySet(), Collections.emptyMap());
7373
}
7474

@@ -115,7 +115,7 @@ public void onFinished() {
115115
activeRecipe = null;
116116
context = null;
117117
status = CraftingStatus.IDLE;
118-
if (isDaemon) {
118+
if (isCoreThread) {
119119
createRecipeSearchTask();
120120
}
121121
}
@@ -179,8 +179,8 @@ public NBTTagCompound serialize() {
179179
if (activeRecipe != null && activeRecipe.getRecipe() != null) {
180180
tag.setTag("activeRecipe", activeRecipe.serialize());
181181
}
182-
if (isDaemon) {
183-
tag.setString("daemonThreadName", threadName);
182+
if (isCoreThread) {
183+
tag.setString("coreThreadName", threadName);
184184
}
185185
if (!permanentModifiers.isEmpty()) {
186186
NBTTagList tagList = new NBTTagList();
@@ -239,14 +239,14 @@ public static RecipeThread deserialize(NBTTagCompound tag, TileFactoryController
239239
thread.permanentModifiers.putAll(permanentModifiers);
240240
thread.semiPermanentModifiers.putAll(semiPermanentModifiers);
241241

242-
// Daemon Thread
243-
if (tag.hasKey("daemonThreadName")) {
244-
Map<String, RecipeThread> threads = factory.getFoundMachine().getDaemonThreads();
245-
RecipeThread daemonThread = threads.get(tag.getString("daemonThreadName"));
246-
if (daemonThread == null) {
242+
// Core Thread
243+
if (tag.hasKey("coreThreadName")) {
244+
Map<String, RecipeThread> threads = factory.getFoundMachine().getCoreThreadPreset();
245+
RecipeThread coreThread = threads.get(tag.getString("coreThreadName"));
246+
if (coreThread == null) {
247247
return thread;
248248
}
249-
return daemonThread.copyDataToAnother(factory, thread);
249+
return coreThread.copyDataToAnother(factory, thread);
250250
}
251251
// Simple Thread
252252
return thread;
@@ -328,15 +328,15 @@ public boolean isIdle() {
328328
}
329329

330330
/**
331-
* 当前线程是否为守护线程(即始终存在)
331+
* 当前线程是否为核心线程(即始终存在)
332332
*/
333-
@ZenGetter("isDaemon")
334-
public boolean isDaemon() {
335-
return isDaemon;
333+
@ZenGetter("isCoreThread")
334+
public boolean isCoreThread() {
335+
return isCoreThread;
336336
}
337337

338338
/**
339-
* 当前线程的名称(仅限守护线程
339+
* 当前线程的名称(仅限核心线程
340340
*/
341341
@ZenGetter("threadName")
342342
public String getThreadName() {
@@ -426,7 +426,7 @@ public void setStatusInfo(String info) {
426426
}
427427

428428
/**
429-
* 为当前线程添加固定配方(仅守护线程生效)。
429+
* 为当前线程添加固定配方(仅核心线程生效)。
430430
*/
431431
@ZenMethod
432432
public RecipeThread addRecipe(String recipeName) {
@@ -451,13 +451,13 @@ public TreeSet<MachineRecipe> getRecipeSet() {
451451
return recipeSet;
452452
}
453453

454-
public RecipeThread copyDaemonThread(TileFactoryController factory) {
454+
public RecipeThread copyCoreThread(TileFactoryController factory) {
455455
return new RecipeThread(factory, true, threadName, recipeSet, permanentModifiers);
456456
}
457457

458458
public RecipeThread copyDataToAnother(TileFactoryController factory, RecipeThread another) {
459459
another.factory = factory;
460-
another.isDaemon = isDaemon;
460+
another.isCoreThread = isCoreThread;
461461
another.threadName = threadName;
462462
another.recipeSet.addAll(recipeSet);
463463
another.permanentModifiers.putAll(permanentModifiers);

0 commit comments

Comments
 (0)