diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/network/WaitList.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/network/WaitList.java')
| -rw-r--r-- | NET/worlds/network/WaitList.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/NET/worlds/network/WaitList.java b/NET/worlds/network/WaitList.java new file mode 100644 index 0000000..6fd3c00 --- /dev/null +++ b/NET/worlds/network/WaitList.java @@ -0,0 +1,48 @@ +package NET.worlds.network; + +import java.util.Vector; + +class WaitList { + private Vector<ConnectionWaiter> _waitList = new Vector<ConnectionWaiter>(); + private Object _parent; + + protected WaitList(Object parent) { + this._parent = parent; + } + + protected synchronized void addWaiter(ConnectionWaiter cw) { + if ((Galaxy.getDebugLevel() & 16384) > 0) { + System.out.println(this._parent + ": waitForConnection(" + cw + ")"); + } + + if (this._waitList.indexOf(cw) < 0) { + this._waitList.addElement(cw); + } + } + + protected synchronized void abortWait(ConnectionWaiter cw) { + assert this._waitList.indexOf(cw) != -1; + + this._waitList.removeElement(cw); + } + + protected synchronized void clear() { + this._waitList = new Vector<ConnectionWaiter>(); + } + + protected synchronized void notify(boolean connected) { + if ((Galaxy.getDebugLevel() & 16384) > 0 && this._waitList.size() > 0) { + System.out.println(this._parent + ": notify(" + connected + ")"); + } + + for (int i = this._waitList.size() - 1; i >= 0; i--) { + ConnectionWaiter cw = this._waitList.elementAt(i); + if ((Galaxy.getDebugLevel() & 16384) > 0) { + System.out.println("\tnotifying " + cw); + } + + cw.connectionCallback(this._parent, connected); + this._waitList.removeElementAt(i); + } + } +} |