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); } } }