ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/util Watchdog.java
Date Fri, 21 Jan 2005 17:37:49 GMT
peterreilly    2005/01/21 09:37:49

  Modified:    src/main/org/apache/tools/ant/util Tag: ANT_16_BRANCH
                        Watchdog.java
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.5   +30 -2     ant/src/main/org/apache/tools/ant/util/Watchdog.java
  
  Index: Watchdog.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/Watchdog.java,v
  retrieving revision 1.7.2.4
  retrieving revision 1.7.2.5
  diff -u -r1.7.2.4 -r1.7.2.5
  --- Watchdog.java	9 Mar 2004 17:01:57 -0000	1.7.2.4
  +++ Watchdog.java	21 Jan 2005 17:37:49 -0000	1.7.2.5
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2002-2004 The Apache Software Foundation
  + * Copyright  2002-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -34,21 +34,36 @@
       private long timeout = -1;
       private boolean stopped = false;
   
  +    /**
  +     * Constructor for Watchdog.
  +     * @param timeout the timeout to use in milliseconds (must be >= 1).
  +     */
       public Watchdog(long timeout) {
           if (timeout < 1) {
  -            throw new IllegalArgumentException("timeout lesser than 1.");
  +            throw new IllegalArgumentException("timeout less than 1.");
           }
           this.timeout = timeout;
       }
   
  +    /**
  +     * Add a timeout observer.
  +     * @param to the timeout observer to add.
  +     */
       public void addTimeoutObserver(TimeoutObserver to) {
           observers.addElement(to);
       }
   
  +    /**
  +     * Remove a timeout observer.
  +     * @param to the timeout observer to remove.
  +     */
       public void removeTimeoutObserver(TimeoutObserver to) {
           observers.removeElement(to);
       }
   
  +    /**
  +     * Inform the observers that a timeout has occured.
  +     */
       protected final void fireTimeoutOccured() {
           Enumeration e = observers.elements();
           while (e.hasMoreElements()) {
  @@ -56,6 +71,9 @@
           }
       }
   
  +    /**
  +     * Start the watch dog.
  +     */
       public synchronized void start() {
           stopped = false;
           Thread t = new Thread(this, "WATCHDOG");
  @@ -63,11 +81,20 @@
           t.start();
       }
   
  +    /**
  +     * Stop the watch dog.
  +     */
       public synchronized void stop() {
           stopped = true;
           notifyAll();
       }
   
  +    /**
  +     * The run method of the watch dog thread.
  +     * This simply does a wait for the timeout time, and
  +     * if the stop flag has not been set when the wait has returned or
  +     * has been interrupted, the watch dog listeners are informed.
  +     */
       public synchronized void run() {
           final long until = System.currentTimeMillis() + timeout;
           long now;
  @@ -75,6 +102,7 @@
               try {
                   wait(until - now);
               } catch (InterruptedException e) {
  +                // Ignore exception
               }
           }
           if (!stopped) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message