Senderpublic class Sender extends Thread A thread that sends the given message on the given link. |
Fields Summary |
---|
public static final long | TIMEOUT | Link | link | LinkMessage | msg | boolean | done | Throwable | exception |
Constructors Summary |
---|
Sender(Link newlink, LinkMessage newmsg)Constructs a new Sender, starts its thread, and waits to give the new
thread a chance to block in send().
link = newlink;
msg = newmsg;
done = false;
exception = null;
start();
Utils.sleep(50);
|
Methods Summary |
---|
public void | await()Waits until the thread finishes or until a timeout has expired.
long timeout = System.currentTimeMillis() + TIMEOUT;
synchronized (this) {
try {
while (System.currentTimeMillis() < timeout && !done) {
wait(TIMEOUT);
}
} catch (InterruptedException ignore) { }
}
| public void | completed(LinkMessage msg, java.lang.Throwable thr)A completion callback. Called after the thread returns from the send()
call. The msg parameter contains the message sent. The thr parameter
contains any Throwable caught, or null there was none. This is
intended to be overridden by a subclass. The default implementation
does nothing.
| public void | run()Sends a message and notifies when done, capturing any exceptions.
try {
link.send(msg);
} catch (Throwable t) {
exception = t;
} finally {
synchronized (this) {
done = true;
notifyAll();
}
}
completed(msg, exception);
|
|