From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/network/WaitList.java | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 NET/worlds/network/WaitList.java (limited to 'NET/worlds/network/WaitList.java') 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 _waitList = new Vector(); + 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(); + } + + 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); + } + } +} -- cgit v1.2.3