Atomic instead of volatile to match counter

This commit is contained in:
2024-05-11 09:15:11 -04:00
parent f7ab38e9a8
commit ba94fabfb8
4 changed files with 18 additions and 17 deletions
+6 -5
View File
@@ -29,6 +29,8 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class WorkOrder implements Delayed {
@@ -41,7 +43,7 @@ public class WorkOrder implements Delayed {
public int workOrderID;
public NPC vendor;
public volatile int slots_used;
public AtomicInteger slots_used = new AtomicInteger(0);
public int total_to_produce;
public int total_produced;
public boolean multiple_slot_request;
@@ -53,7 +55,7 @@ public class WorkOrder implements Delayed {
public int suffixToken;
public long rollingDuration;
public long completionTime;
public volatile boolean runCompleted = false;
public AtomicBoolean runCompleted = new AtomicBoolean(false);
// This collection is serialized to the vendor rolling window in ManageNPCMsg.
@@ -70,7 +72,7 @@ public class WorkOrder implements Delayed {
this.workOrderID = jsonWorkOrder.getInt("workOrderID");
this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor"));
this.slots_used = jsonWorkOrder.getInt("slots_used");
this.slots_used.set(jsonWorkOrder.getInt("slots_used"));
this.total_to_produce = jsonWorkOrder.getInt("total_to_produce");
this.total_produced = jsonWorkOrder.getInt("total_produced");
this.multiple_slot_request = jsonWorkOrder.getBoolean("multiple_slot_request");
@@ -78,10 +80,9 @@ public class WorkOrder implements Delayed {
this.item_name_override = jsonWorkOrder.getString("item_name_override");
this.prefixToken = jsonWorkOrder.getInt("prefixToken");
this.suffixToken = jsonWorkOrder.getInt("suffixToken");
this.slots_used = jsonWorkOrder.getInt("slots_used");
this.rollingDuration = jsonWorkOrder.getLong("rollingDuration");
this.completionTime = jsonWorkOrder.getLong("completionTime");
this.runCompleted = jsonWorkOrder.getBoolean("runCompleted");
this.runCompleted.set(jsonWorkOrder.getBoolean("runCompleted"));
JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost");