src/main/java/org/jboss/util/timeout/TimeoutPriorityQueueImpl.java
void checkTree()
   {
      assertExpr(size >= 0);
      assertExpr(size < queue.length);
      assertExpr(queue[0] == null);
      if (size > 0)
      {
         assertExpr(queue[1] != null);
         assertExpr(queue[1].index == 1);
         for (int i = 2; i <= size; ++i)
         {
            assertExpr(queue[i] != null);
            assertExpr(queue[i].index == i);
            assertExpr(queue[i >> 1].time <= queue[i].time); // parent fires first
         }
         for (int i = size + 1; i < queue.length; ++i)
            assertExpr(queue[i] == null);
      }
   }

   /**
    * Debugging helper.
    */
   private void assertExpr(boolean expr)
   {
      if (!expr)
         throw new IllegalStateException("***** assert failed *****");
   }

   /**
    *  Our private Timeout implementation.
    */
   private class TimeoutExtImpl implements TimeoutExt
   {
      /** Done */
      static final int DONE = -1;

      /** In timeout */
      static final int TIMEOUT = -2;

      /** Index in the queue */
      int index;

      /** Time of the timeout */
      long time;

      /** The timeout target */
      TimeoutTarget target;

      public long getTime()
      {
         return time;
      }

      public TimeoutTarget getTimeoutTarget()
      {
         return target;
      }

      public void done()
      {
         index = DONE;
      }
      
      public boolean cancel()
      {
         return remove(this);
      }
   }
}
void checkTree()
   {
      assertExpr(size >= 0);
      assertExpr(size < queue.length);
      assertExpr(queue[0] == null);
      if (size > 0)
      {
         assertExpr(queue[1] != null);
         assertExpr(queue[1].index == 1);
         for (int i = 2; i <= size; ++i)
         {
            assertExpr(queue[i] != null);
            assertExpr(queue[i].index == i);
            assertExpr(queue[i >> 1].time <= queue[i].time); // parent fires first
         }
         for (int i = size + 1; i < queue.length; ++i)
            assertExpr(queue[i] == null);
      }
   }

   /**
    * Debugging helper.
    */
   private void assertExpr(boolean expr)
   {
      if (!expr)
         throw new IllegalStateException("***** assert failed *****");
   }

   /**
    *  Our private Timeout implementation.
    */
   private class TimeoutExtImpl implements TimeoutExt
   {
      /** Done */
      static final int DONE = -1;

      /** In timeout */
      static final int TIMEOUT = -2;

      /** Index in the queue */
      int index;

      /** Time of the timeout */
      long time;

      /** The timeout target */
      TimeoutTarget target;

      public long getTime()
      {
         return time;
      }

      public TimeoutTarget getTimeoutTarget()
      {
         return target;
      }

      public void done()
      {
         index = DONE;
      }
      
      public boolean cancel()
      {
         return remove(this);
      }
   }
}
void checkTree ( ) { assertExpr ( size >= 0 ) ; assertExpr ( size < queue . length ) ; assertExpr ( queue [ 0 ] == null ) ; if ( size > 0 ) { assertExpr ( queue [ 1 ] != null ) ; assertExpr ( queue [ 1 ] . index == 1 ) ; for ( int i = 2 ; i <= size ; ++ i ) { assertExpr ( queue [ i ] != null ) ; assertExpr ( queue [ i ] . index == i ) ; assertExpr ( queue [ i >> 1 ] . time <= queue [ i ] . time ) ; // parent fires first } for ( int i = size + 1 ; i < queue . length ; ++ i ) assertExpr ( queue [ i ] == null ) ; } } /**
    * Debugging helper.
    */ private void assertExpr ( boolean expr ) { if ( ! expr ) throw new IllegalStateException ( "***** assert failed *****" ) ; } /**
    *  Our private Timeout implementation.
    */ private class TimeoutExtImpl implements TimeoutExt { /** Done */ static final int DONE = - 1 ; /** In timeout */ static final int TIMEOUT = - 2 ; /** Index in the queue */ int index ; /** Time of the timeout */ long time ; /** The timeout target */ TimeoutTarget target ; public long getTime ( ) { return time ; } public TimeoutTarget getTimeoutTarget ( ) { return target ; } public void done ( ) { index = DONE ; } public boolean cancel ( ) { return remove ( this ) ; } } }
Check invariants of the queue.
Check invariants of the queue .