com.marringtons.util
Class Idle

java.lang.Object
  extended bycom.marringtons.util.Idle

public class Idle
extends Object

This is a singleton called by the main application loop when the application has had nothing to do for at least a minute. Low priority processes register with this class to be called during idle periods.

 class myClass implements IdleInterface
   {
     myClass() { Idle.register( this); }
     public void whileIdling() { cleanup(); }
   }
 

Author:
Paul Marrington

Method Summary
static void afterInterval(IdleInterface process, Time interval)
          Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day.
static void deregister(IdleInterface process)
          A process must be deregistered if no longer needed or it can never be freed.
static void process()
          Called by the main application loop whenever nothing happens for at least a minute.
static void register(IdleInterface process)
          Processes use this singleton entry point to register low priority processes to be called while the system is idling.
static void until(IdleInterface process, Date date)
          Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day.
static void until(IdleInterface process, Time tod)
          Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

process

public static void process()
Called by the main application loop whenever nothing happens for at least a minute. If the process is reading from a socket or connection, it can use the timeout parameter to define an idling period.


register

public static void register(IdleInterface process)
Processes use this singleton entry point to register low priority processes to be called while the system is idling. These processes should not be long running in themselves. If they are then they should be start a separate thread that can be terminated if the system becomes busy again.

Parameters:
process - to call while idling.

until

public static void until(IdleInterface process,
                         Time tod)
Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day. These processes should not be long running in themselves. If they are then they should be start a separate thread that can be terminated if the system becomes busy again.
 // run after tomorrow midday.
 Idle.until( myObject, new Time( 1, 12, 0, 0));
 

Parameters:
process - process To call while idling.
tod - Time object specifying time of day to run process after.

until

public static void until(IdleInterface process,
                         Date date)
Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day. These processes should not be long running in themselves. If they are then they should be start a separate thread that can be terminated if the system becomes busy again.
 // run after 3 days at this time of day.
 Idle.until( myObject, new Date().add( 0, 0, 3));
 

Parameters:
process - process To call while idling.
date - Date object specifying date to run process after.

afterInterval

public static void afterInterval(IdleInterface process,
                                 Time interval)
Processes use this singleton entry point to register low priority processes to be called once while the system is idling - but after a specified time of day. These processes should not be long running in themselves. If they are then they should be start a separate thread that can be terminated if the system becomes busy again.
 // run after 1-1/2 hours.
 Idle.afterInterval( myObject, new Time( 0, 1, 30, 0));
 

Parameters:
process - process To call while idling.
interval - Time object specifying interval before running idle process.

deregister

public static void deregister(IdleInterface process)
A process must be deregistered if no longer needed or it can never be freed. Not an efficient implementation, but the list is unlikely to be long and even more unlikely that deregistration is necessary.

Parameters:
process - that was being called while idling.


Copyright © 2005 Paul Marrington http://library.marringtons.com