Fixed FRCSim artf2619, and misc reformatting.

Change-Id: I7133f46f88f7e2cb2451c2a6714daa8f3f368b40
This commit is contained in:
Colby Skeggs
2014-07-22 13:10:23 -07:00
parent 461e359484
commit 2dd45c3ea6
5 changed files with 86 additions and 53 deletions

View File

@@ -79,6 +79,27 @@ public class Publisher<T extends Message> implements PublisherRecord {
}
}
listeners.add(conn);
this.notifyAll();
}
public synchronized void waitForConnection() throws InterruptedException {
while (this.listeners.isEmpty()) {
this.wait();
}
}
public synchronized boolean waitForConnection(long timeout_millis) throws InterruptedException {
long start = System.currentTimeMillis();
while (this.listeners.isEmpty()) {
long remain = timeout_millis - (System.currentTimeMillis() - start);
if (remain <= 0) {
break;
}
this.wait(remain);
}
return !this.listeners.isEmpty();
}
public void setLatchMode(boolean b) {