org.jnetpcap.nio
Class DisposableGC

java.lang.Object
  extended by org.jnetpcap.nio.DisposableGC

public final class DisposableGC
extends java.lang.Object

Specialized garbage-collector that invokes the. DisposableReference.dispose() method immediately as soon as a DisposableReference becomes unreferancable and put on the main garbage collector's list.

Author:
markbe

Method Summary
 void drainRefQueue()
          Drain ref queue.
 void drainRefQueue(long timeout)
          Drain ref queue.
 long getCleanupThreadTimeout()
          Gets the cleanup thread timeout.
static DisposableGC getDefault()
          Gets the default.
 void invokeSystemGCAndWait()
          Invoke system gc and wait.
 void invokeSystemGCWithMarker()
          Issues a JVM GC request, while injecting a marker reference to be cleaned up by the very same JVM GC run.
 boolean isCleanupComplete()
          Checks if is cleanup complete.
 boolean isCleanupThreadActive()
          Checks if is cleanup thread active.
 boolean isVerbose()
          Checks if is verbose.
 boolean isVVerbose()
          Checks if is v verbose.
 boolean isVVVerbose()
          Checks if is vV verbose.
 void setCleanupThreadTimeout(long timeout)
          Sets the cleanup thread timeout.
 void setVerbose(boolean verbose)
          Sets the verbose.
 void setVVerbose(boolean vverbose)
          Sets the v verbose.
 void setVVVerbose(boolean vvverbose)
          Sets the vV verbose.
 void startCleanupThread()
          Start cleanup thread.
 void stopCleanupThread()
          Stop cleanup thread.
 void waitForForcableCleanup()
          Wait for forcable cleanup.
 boolean waitForForcableCleanup(long timeout)
          Wait for forcable cleanup.
 void waitForFullCleanup()
          Wait for full cleanup.
 boolean waitForFullCleanup(long timeout)
          Wait for full cleanup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefault

public static DisposableGC getDefault()
Gets the default.

Returns:
the default

drainRefQueue

public void drainRefQueue()
Drain ref queue.


drainRefQueue

public void drainRefQueue(long timeout)
                   throws java.lang.IllegalArgumentException,
                          java.lang.InterruptedException
Drain ref queue.

Parameters:
timeout - the timeout
Throws:
java.lang.IllegalArgumentException - the illegal argument exception
java.lang.InterruptedException - the interrupted exception

getCleanupThreadTimeout

public long getCleanupThreadTimeout()
Gets the cleanup thread timeout.

Returns:
the cleanup thread timeout

invokeSystemGCAndWait

public void invokeSystemGCAndWait()
Invoke system gc and wait.


invokeSystemGCWithMarker

public void invokeSystemGCWithMarker()
Issues a JVM GC request, while injecting a marker reference to be cleaned up by the very same JVM GC run. Until our marker reference is not cleaned up, we do not issue another JVM GC since this means that previous GC run has not reached our marker reference yet.


isCleanupComplete

public boolean isCleanupComplete()
Checks if is cleanup complete.

Returns:
true, if is cleanup complete

isCleanupThreadActive

public boolean isCleanupThreadActive()
Checks if is cleanup thread active.

Returns:
true, if is cleanup thread active

isVerbose

public boolean isVerbose()
Checks if is verbose.

Returns:
the verbose

isVVerbose

public boolean isVVerbose()
Checks if is v verbose.

Returns:
the vverbose

isVVVerbose

public boolean isVVVerbose()
Checks if is vV verbose.

Returns:
the vvverbose

setCleanupThreadTimeout

public void setCleanupThreadTimeout(long timeout)
Sets the cleanup thread timeout.

Parameters:
timeout - the new cleanup thread timeout

setVerbose

public void setVerbose(boolean verbose)
Sets the verbose.

Parameters:
verbose - the verbose to set

setVVerbose

public void setVVerbose(boolean vverbose)
Sets the v verbose.

Parameters:
vverbose - the vverbose to set

setVVVerbose

public void setVVVerbose(boolean vvverbose)
Sets the vV verbose.

Parameters:
vvverbose - the vvverbose to set

startCleanupThread

public void startCleanupThread()
Start cleanup thread.


stopCleanupThread

public void stopCleanupThread()
                       throws java.lang.InterruptedException
Stop cleanup thread.

Throws:
java.lang.InterruptedException - the interrupted exception

waitForForcableCleanup

public void waitForForcableCleanup()
                            throws java.lang.InterruptedException
Wait for forcable cleanup.

Throws:
java.lang.InterruptedException - the interrupted exception

waitForForcableCleanup

public boolean waitForForcableCleanup(long timeout)
                               throws java.lang.InterruptedException
Wait for forcable cleanup.

Parameters:
timeout - the timeout
Returns:
true, if successful
Throws:
java.lang.InterruptedException - the interrupted exception

waitForFullCleanup

public void waitForFullCleanup()
                        throws java.lang.InterruptedException
Wait for full cleanup.

Throws:
java.lang.InterruptedException - the interrupted exception

waitForFullCleanup

public boolean waitForFullCleanup(long timeout)
                           throws java.lang.InterruptedException
Wait for full cleanup.

Parameters:
timeout - the timeout
Returns:
true, if successful
Throws:
java.lang.InterruptedException - the interrupted exception