Skip to content

Commit

Permalink
Change the prison TPS monitor to a singleton.
Browse files Browse the repository at this point in the history
Will be using this in the near future to monitor system loads.
  • Loading branch information
rbluer committed Sep 7, 2024
1 parent d1c1168 commit cd4e514
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.


# 3.3.0-alpha.18d 2024-09-06
# 3.3.0-alpha.18d 2024-09-07


* **Change the prison TPS monitor to a singleton.**
Will be using this in the near future to monitor system loads.


* **Mines: Minor change: Simplify how the command is ran so there is one exit point instead of two.**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@
* </p>
*
*/
public class PrisonTPS
public class PrisonTPSSingleton
implements PrisonRunnable {

private static PrisonTPSSingleton instance;

/**
* Note: Normally the task would have to run each tick, but by specifying the
* SUBMIT_TICKS_INTERVAL it can skip a number of ticks to reduce the
Expand Down Expand Up @@ -206,6 +208,23 @@ public class PrisonTPS
public static final Object tpsLock = new Object();


private PrisonTPSSingleton() {
super();
}


public static PrisonTPSSingleton getInstance() {
if ( instance == null ) {
synchronized ( PrisonTPSSingleton.class ) {
if ( instance == null ) {
instance = new PrisonTPSSingleton();
}
}
}
return instance;
}


// When submitted, taskId identifies the job. A value of -1 indicates the job
// failed to be submitted, or is not valid.
private int taskId = -1;
Expand Down

0 comments on commit cd4e514

Please sign in to comment.