Package util

Examples of util.Timer


      lblX.setImage(img);
    }


    filterDelayTimer = new Timer("Filter");
    filterDelayTimer.addEvent(SystemTime.getCurrentTime() + 300,
        new TimerEventPerformer() {
          public void perform(TimerEvent event) {
            filterDelayTimer.destroy();
            filterDelayTimer = null;
View Full Code Here


    return(
      new AggregatedList()
      {
        AEMonitor  timer_mon  = new AEMonitor( "aggregatedList" );
       
        Timer    timer = new Timer( "AggregatedList" );
        TimerEvent  event;
       
        List    list  = new ArrayList();
       
        public void
        add(
          Object  obj )
        {
         
          List  dispatch_now = null;
         
          try{
            timer_mon.enter();
           
              // if the list is full kick off a dispatch and reset the list
           
            if max_queue_size > 0 &&
                max_queue_size  == list.size()){
             
              dispatch_now = list;
             
              list  = new ArrayList();
             
            }
             
            list.add( obj );
           
              // set up a timer to wakeup in required time period
           
            long  now = SystemTime.getCurrentTime();
         
            if ( event != null ){
             
              event.cancel();
            }
           
            event =
              timer.addEvent(
                  now + idle_dispatch_time,
                  new TimerEventPerformer()
                  {
                    public void
                    perform(
                      TimerEvent  event )
                    {
                      dispatch();
                    }
                  });
          }finally{
           
            timer_mon.exit();
          }
         
          if ( dispatch_now != null ){
           
            dispatch( dispatch_now );
          }
        }

        public Object
        remove(
          Object  obj )
        {
          Object  res = null;
         
          try{
            timer_mon.enter();
         
            res = list.remove( obj )?obj:null;
             
            if ( res != null ){
             
              long  now = SystemTime.getCurrentTime();
             
              if ( event != null ){
               
                event.cancel();
              }
               
              if ( list.size() == 0 ){
               
                event  = null;
               
              }else{
               
                event =
                  timer.addEvent(
                      now + idle_dispatch_time,
                      new TimerEventPerformer()
                      {
                        public void
                        perform(
                          TimerEvent  event )
                        {
                          dispatch();
                        }
                      });
              }
            }
          }finally{
           
            timer_mon.exit();
          }
         
          return( res );
        }
       
        protected void
        dispatch()
        {
          List  dispatch_list;
         
          try{
            timer_mon.enter();
         
            dispatch_list  = list;
           
            list  = new ArrayList();
           
          }finally{
           
            timer_mon.exit();
          }
         
          dispatch( dispatch_list );
        }

        protected void
        dispatch(
          List    l )
        {
          if ( l.size() > 0 ){
           
            try{
              acceptor.accept( l );
             
            }catch( Throwable e ){
             
              Debug.printStackTrace(e);
            }
          }
        }
       
        public void
        destroy()
        {
          dispatch();
         
          timer.destroy();
        }
      });
  }
View Full Code Here

   
    if ( enabled ){
     
      if ( average_timer == null ){
       
        average_timer = new Timer( "AzureusCoreStats:average" );
       
        averages = new HashMap();
       
        average_timer.addPeriodicEvent(
          AVERAGE_PERIOD,
View Full Code Here

  private long total_reads = 0;
  private long total_writes = 0;
 
 
  public TransportStats() {
    Timer printer = new Timer("TransportStats:Printer");
    printer.addPeriodicEvent(
        PRINT_INTERVAL,
        new TimerEventPerformer() {
          public void perform( TimerEvent ev ) {
            printStats();
          }
View Full Code Here

         
          System.out.println( "Stored " + i + " values" );
        }
      }
     
      Timer  timer = new Timer("");
     
      timer.addPeriodicEvent(
        10000,
        new TimerEventPerformer()
        {
          public void
          perform(
View Full Code Here

TOP

Related Classes of util.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.