diff options
Diffstat (limited to 'NET/worlds/console/StatRateNode.java')
| -rw-r--r-- | NET/worlds/console/StatRateNode.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/NET/worlds/console/StatRateNode.java b/NET/worlds/console/StatRateNode.java new file mode 100644 index 0000000..84e33dd --- /dev/null +++ b/NET/worlds/console/StatRateNode.java @@ -0,0 +1,66 @@ +package NET.worlds.console; + +import NET.worlds.core.Std; +import java.awt.List; + +class StatRateNode extends StatMan implements MainCallback { + private static StatRateNode _singleInstance = new StatRateNode(); + private int _lastTime; + private static final int TITLE = 0; + private static final int BLANK1 = 1; + private static final int THREADS = 2; + private int lastQueueLength; + + public static StatRateNode getNode() { + return _singleInstance; + } + + private StatRateNode() { + StatisticsRoot.getNode().addChild(this); + } + + @Override + public String toString() { + return "Active Threads"; + } + + @Override + synchronized void grabList(List list) { + super.grabList(list); + Main.register(this); + } + + @Override + synchronized void releaseList(boolean terminalCallback) { + if (!terminalCallback) { + Main.unregister(this); + } + + super.releaseList(terminalCallback); + } + + @Override + public synchronized void mainCallback() { + int thisTime = Std.getFastTime(); + if (thisTime - this._lastTime > 1000) { + this.updateList(); + this._lastTime = thisTime; + } + } + + @Override + void createList() { + this._grabbedList.add("Active Thread Statistics", 0); + this._grabbedList.add("", 1); + this.lastQueueLength = Main.queueLength(); + this._grabbedList.add("Number main threads: " + this.lastQueueLength, 2); + } + + @Override + void updateList() { + if (Main.queueLength() != this.lastQueueLength) { + this.lastQueueLength = Main.queueLength(); + this._grabbedList.replaceItem("Number main threads: " + this.lastQueueLength, 2); + } + } +} |