Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 59   Methods: 5
NCLOC: 32   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
DelayedPromise.java 0% 0% 0% 0%
coverage
 1   
 package nmp.util;
 2   
 
 3   
 /**
 4   
  * Used to store the result of an operation not yet known
 5   
  */
 6   
 public class DelayedPromise
 7   
         implements Promise
 8   
 {
 9   
     private Object result;
 10   
     private boolean completed;
 11   
 
 12  0
     public DelayedPromise() {
 13  0
         completed = false;
 14   
     }
 15   
     
 16   
     /**
 17   
      * Returns true if the result of invocation is already known
 18   
      */
 19  0
     public boolean isResultAvailable() {
 20  0
         return completed;
 21   
     }
 22   
     
 23   
     /**
 24   
      * Gets the result of the preformed operation. This method blocks until the result
 25   
      * is received.
 26   
      */
 27  0
     public Object getResult() {
 28  0
         waitForResult( 0);
 29  0
         return result;
 30   
     }
 31   
 
 32   
     /**
 33   
      * Gets the result of the preformed operation. This method blocks until the result
 34   
      * is received.
 35   
      */
 36  0
     public synchronized void setResult( Object result) {
 37  0
         this.result = result;
 38  0
         completed = true;
 39  0
         this.notifyAll();
 40   
     }
 41   
 
 42   
     /**
 43   
      * Waits (a given time) until the result of the operation is available.
 44   
      * 
 45   
      * @param mills The maximum time to wait in miliseconds. 0 - means waiting forever.
 46   
      * @return Returns true if result is available
 47   
      */
 48  0
     public synchronized boolean waitForResult( long mills) {
 49  0
         if( completed)
 50  0
             return true;
 51  0
         try {
 52  0
             this.wait( mills);
 53   
         }catch( Exception ex) {
 54  0
             Log.errorDump( ex);
 55   
         }
 56  0
         return completed;
 57   
     }
 58   
 }
 59