aboutsummaryrefslogtreecommitdiff
path: root/src/Waiter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Waiter.java')
-rw-r--r--src/Waiter.java50
1 files changed, 11 insertions, 39 deletions
diff --git a/src/Waiter.java b/src/Waiter.java
index d625217..4679f09 100644
--- a/src/Waiter.java
+++ b/src/Waiter.java
@@ -1,5 +1,5 @@
/**
- * a helper class to implement faitForClient, Wait for Message
+ * a helper class to implement "Wait for Message" in {@link Ivy.waitForMsg}
* @author Yannick Jestin
* @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
*
@@ -10,45 +10,17 @@
package fr.dgac.ivy ;
-class Waiter implements Runnable, IvyMessageListener {
- private static final int INCREMENT = 100;
- int timeout;
- private IvyClient received=null;
- private boolean forever=false;
- private Thread t;
+class Waiter extends WaitFor implements IvyMessageListener {
- public Waiter(int timeout) {
- this.timeout=timeout;
- if (timeout<=0) forever=true;
- t=new Thread(this);
- t.setName("Ivy Waiter thread, for message");
- }
-
- public IvyClient waitFor() {
- t.start();
- try { t.join(); } catch (InterruptedException ie) { return null; }
- return received;
- }
+ public Waiter(int timeout) {
+ super(timeout);
+ setName("Ivy Waiter thread, for message");
+ }
- public void run() {
- boolean encore=true;
- // System.out.println("DEV Waiter start");
- while (encore) {
- try {
- if (INCREMENT>0) Thread.sleep(INCREMENT);
- if (!forever) {
- timeout-=INCREMENT;
- if (timeout<=0) encore=false;
- }
- } catch (InterruptedException ie) {
- break;
- }
- }
- // System.out.println("DEV Waiter stop");
- }
+ boolean check() { return false; }
- public void receive(IvyClient ic, String[] args) {
- received=ic;
- t.interrupt();
- }
+ public void receive(IvyClient ic, String[] args) {
+ received=ic;
+ interrupt();
}
+}