diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/console/Main.java | |
| download | worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip | |
Diffstat (limited to 'NET/worlds/console/Main.java')
| -rw-r--r-- | NET/worlds/console/Main.java | 279 |
1 files changed, 279 insertions, 0 deletions
diff --git a/NET/worlds/console/Main.java b/NET/worlds/console/Main.java new file mode 100644 index 0000000..d2375ae --- /dev/null +++ b/NET/worlds/console/Main.java @@ -0,0 +1,279 @@ +/* */ package NET.worlds.console; +/* */ +/* */ import NET.worlds.core.IniFile; +/* */ import NET.worlds.core.Std; +/* */ import java.io.PrintStream; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class Main +/* */ { +/* 111 */ public static int profile = IniFile.gamma().getIniInt( +/* 112 */ "Profile", 0); +/* */ +/* */ +/* */ private static Thread mainThread; +/* */ +/* */ +/* */ +/* */ public static void mainLoop() +/* */ { +/* 121 */ mainThread = Thread.currentThread(); +/* */ +/* 123 */ while (!stopFlag) +/* */ { +/* */ +/* */ +/* */ +/* */ +/* 129 */ MainCallback cb = getNextCallback(); +/* */ +/* 131 */ if (cb != null) { +/* 132 */ if (profile != 0) { +/* 133 */ int start = Std.getRealTime(); +/* 134 */ long startBytes = Runtime.getRuntime().freeMemory(); +/* 135 */ cb.mainCallback(); +/* 136 */ int dur = Std.getRealTime() - start; +/* 137 */ long used = startBytes - Runtime.getRuntime().freeMemory(); +/* 138 */ if ((dur > profile) && (!(cb instanceof Console))) { +/* 139 */ System.out.println("Took " + dur + "ms and " + used + +/* 140 */ " bytes to call mainCallback " + cb); +/* */ } +/* */ } else { +/* 143 */ cb.mainCallback(); +/* */ } +/* */ } +/* */ +/* 147 */ Thread.yield(); +/* */ } +/* */ +/* */ +/* */ +/* */ MainCallback cb; +/* */ +/* */ +/* */ +/* 156 */ while ((cb = getNextCallback()) != null) { MainCallback cb; +/* 157 */ if ((cb instanceof MainTerminalCallback)) { +/* 158 */ ((MainTerminalCallback)cb).terminalCallback(); +/* */ +/* 160 */ Thread.yield(); +/* */ } +/* */ else +/* */ { +/* 164 */ unregister(cb); +/* */ } +/* */ } +/* */ +/* 168 */ mainThread = null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static void end() +/* */ { +/* 179 */ stopFlag = true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static boolean isMainThread() +/* */ { +/* 190 */ return Thread.currentThread() == mainThread; +/* */ } +/* */ +/* */ +/* 194 */ private static boolean stopFlag = false; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 203 */ private static Vector<MainCallback> v = new Vector(); +/* */ +/* */ public static int queueLength() { +/* 206 */ return v.size(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 216 */ private static int lastAt = -1; +/* */ +/* */ +/* */ +/* */ +/* */ private static MainCallback getNextCallback() +/* */ { +/* */ MainCallback cb; +/* */ +/* */ +/* */ +/* 227 */ synchronized (v) { +/* 228 */ int n = v.size(); +/* 229 */ MainCallback cb; if (n == 0) { +/* 230 */ lastAt = -1; +/* 231 */ cb = null; +/* */ } else { +/* 233 */ if (++lastAt >= n) +/* 234 */ lastAt = 0; +/* 235 */ cb = (MainCallback)v.elementAt(lastAt); +/* */ } +/* */ } +/* */ MainCallback cb; +/* 239 */ return cb; +/* */ } +/* */ +/* */ public static void register(MainCallback x) +/* */ { +/* 244 */ v.addElement(x); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static void unregister(MainCallback x) +/* */ { +/* 264 */ synchronized (v) { +/* 265 */ int i = v.indexOf(x); +/* 266 */ v.removeElementAt(i); +/* */ +/* 268 */ if (lastAt >= i) { +/* 269 */ lastAt -= 1; +/* */ } +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\Main.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |