blob: 6fd3c0080998348ef2511dbb6e9bd5652bd9f3de (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
}
}
}
|