dasher.net
Class NetDashGC

java.lang.Object
  extended by java.util.TimerTask
      extended by dasher.net.NetDashGC
All Implemented Interfaces:
java.lang.Runnable

public class NetDashGC
extends java.util.TimerTask

This task is scheduled to run every 60 seconds to identify and terminate idle NetDasher sessions.

The scheduling is set up by NetDasherListener.

Each time the thread is run, the following is checked against each Dasher in the Map supplied by NetDasherListener.

  1. First, the Dasher in question is locked.
  2. Next we check if it is both idle and has not already been destroyed.
  3. If it fulfils both these conditions, its destroy() method. The NetDashConnectionHandler should free as much of Dasher as possible at this point.
  4. NetDashConnectionHandlers which have been destroyed are removed from the Map, such that they can be garbage collected.
  5. Finally, the lock is released.


Field Summary
protected  java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashers
          Map which will be checked for idle Dashers when this thread is run
 
Constructor Summary
NetDashGC(java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashs)
          Creates a new GC thread attached to a given Map of Dashers.
 
Method Summary
 void run()
          Checks for idle dashers; see the class summary for details.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Dashers

protected java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashers
Map which will be checked for idle Dashers when this thread is run

Constructor Detail

NetDashGC

public NetDashGC(java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashs)
Creates a new GC thread attached to a given Map of Dashers.

Parameters:
Dashs - Map to check for idle Dashers when run
Method Detail

run

public void run()
Checks for idle dashers; see the class summary for details.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask