Skip to content

Commit

Permalink
Multi Threading fix?
Browse files Browse the repository at this point in the history
Take a sledgehammer and make every method synchronized because I do not feel like learning how multi-threading works so make everything thread safe. A perfect solution. 50% chance this gets reverted. Although the next solution is just make every variable volatile and I don't know where I'm going with this description.
  • Loading branch information
Mason-Lam committed Jun 30, 2022
1 parent 3f2f85e commit de0d9b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/frc/team3128/ConstantsInt.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void initTempConstants() {
}

//Change the value of a constant
public static void updateConstant(String category, String name, String value) throws IllegalArgumentException {
public static synchronized void updateConstant(String category, String name, String value) throws IllegalArgumentException {
String callerClass = Thread.currentThread().getStackTrace()[2].getClassName();
if(!callerClass.equals("frc.team3128.common.narwhaldashboard.NarwhalDashboard")) throw new IllegalArgumentException("Caller class is not valid!");
Class<?> clazz = categories.get(category); //Get the specified Constant class
Expand Down Expand Up @@ -132,12 +132,12 @@ private static Object parseData(String value) {
}

//Return each field of a constants class
public static ArrayList<Field> getConstantInfo(String category) {
public static synchronized ArrayList<Field> getConstantInfo(String category) {
return editConstants.get(category);
}

//Make a constant editable
public static void addConstant(String category, String name) throws IllegalArgumentException{
public static synchronized void addConstant(String category, String name) throws IllegalArgumentException{
try {
Field field = categories.get(category).getField(name);
try {
Expand Down

0 comments on commit de0d9b1

Please sign in to comment.