Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
remove singleton pattern. add comment that initializeMechansms will o…
Browse files Browse the repository at this point in the history
…nly be called once.
  • Loading branch information
dejabot committed Jan 19, 2024
1 parent 8874036 commit ef7967f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/team766/hal/RobotConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface RobotConfigurator {

/**
* Initializes the {@link Mechanism}s for this robot.
*
* Will only be called once by the framework.
*/
void initializeMechanisms();

Expand Down
20 changes: 6 additions & 14 deletions src/main/java/com/team766/robot/gatorade/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,14 @@ public class Robot implements RobotConfigurator {
public static Drive drive;
public static Lights lights;

private static boolean initialized = false;

@Override
public void initializeMechanisms() {
if (!initialized) {
// get rid of the synchronized if there are no thread-safety considerations
synchronized (Robot.class) {
intake = new Intake();
wrist = new Wrist();
elevator = new Elevator();
shoulder = new Shoulder();
drive = new Drive();
lights = new Lights();
initialized = true;
}
}
intake = new Intake();
wrist = new Wrist();
elevator = new Elevator();
shoulder = new Shoulder();
drive = new Drive();
lights = new Lights();
}

@Override
Expand Down

0 comments on commit ef7967f

Please sign in to comment.