src/org/jnetpcap/nio/DisposableGC.java
void drainRefQueueLoop() throws InterruptedException {

		deltaCount = 0;
		deltaSize = 0;
		final long timeout = cleanupTimeout.get();
		long ts = System.currentTimeMillis();
		while (true) {

			final DisposableReference ref =
					(DisposableReference) refQueue.remove(timeout);

			if (ref != null) { // We have a reference to dispose of
				if (deltaCount == 0) { // First one
					if (vvverbose && cleanupThreadProcessing.get() == false) {
						logBusy();
					}
					cleanupThreadProcessing.set(true);
					synchronized (cleanupThreadProcessing) {
						cleanupThreadProcessing.notifyAll(); // Signal start
					}
				}
				deltaCount++;
				deltaSize += ref.size();

				/**
				 * Keep message coming even if we are continuously processing.
				 */
				if (vverbose && (deltaCount % 10000) == 0) {
					sortGenerations();
					logUsage();
				}

				/*
				 * Means, we just finished processing
				 */
			} else if (deltaCount != 0 && (System.currentTimeMillis() - ts) >= 1000) {
				ts = System.currentTimeMillis();
				sortGenerations();
				if (verbose && deltaCount > 00) {
					logUsage();
				}

				deltaCount = 0;
				deltaSize = 0;
				cleanupThreadProcessing.set(false);

				synchronized (cleanupThreadProcessing) { // Signal finish
					cleanupThreadProcessing.notifyAll();
				}
				if (vvverbose) {
					logIdle();
				}
			}

			if (ref == null) {
				if (cleanupThreadActive.get()) {
					if (memorySemaphore.hasQueuedThreads()) {
						invokeSystemGC();
					}

					continue; // Null due to timeout
				} else {
					if (verbose) {
						logFinished();
					}
					break;
				}
			}

			dispose(ref);
		}

		if (verbose && deltaCount != 0) {
			System.out.printf("DisposableGC: disposed of %d entries [total=%dM]%n",
					deltaCount,
					totalDisposed / 1000000);
			deltaCount = 0;
		}
	}
/**
	 * Drain ref queue loop.
	 * 
	 * @throws InterruptedException
	 *           the interrupted exception
	 */
Drain ref queue loop.

@throws InterruptedException
the interrupted exception
Drain ref queue loop . @throws InterruptedException the interrupted exception
void drainRefQueueLoop() throws InterruptedException {
		deltaCount = 0;
		deltaSize = 0;
		final long timeout = cleanupTimeout.get();
		long ts = System.currentTimeMillis();
		while (true) {
			final DisposableReference ref =
					(DisposableReference) refQueue.remove(timeout);
			if (ref != null) { 
				if (deltaCount == 0) { 
					if (vvverbose && cleanupThreadProcessing.get() == false) {
						logBusy();
					}
					cleanupThreadProcessing.set(true);
					synchronized (cleanupThreadProcessing) {
						cleanupThreadProcessing.notifyAll(); 
					}
				}
				deltaCount++;
				deltaSize += ref.size();
				/**
				 * Keep message coming even if we are continuously processing.
				 */
				if (vverbose && (deltaCount % 10000) == 0) {
					sortGenerations();
					logUsage();
				}
				/*
				 * Means, we just finished processing
				 */
			} else if (deltaCount != 0 && (System.currentTimeMillis() - ts) >= 1000) {
				ts = System.currentTimeMillis();
				sortGenerations();
				if (verbose && deltaCount > 00) {
					logUsage();
				}
				deltaCount = 0;
				deltaSize = 0;
				cleanupThreadProcessing.set(false);
				synchronized (cleanupThreadProcessing) { 
					cleanupThreadProcessing.notifyAll();
				}
				if (vvverbose) {
					logIdle();
				}
			}
			if (ref == null) {
				if (cleanupThreadActive.get()) {
					if (memorySemaphore.hasQueuedThreads()) {
						invokeSystemGC();
					}
					continue; 
				} else {
					if (verbose) {
						logFinished();
					}
					break;
				}
			}
			dispose(ref);
		}
		if (verbose && deltaCount != 0) {
			System.out.printf("DisposableGC: disposed of %d entries [total=%dM]%n",
					deltaCount,
					totalDisposed / 1000000);
			deltaCount = 0;
		}
	}
void drainRefQueueLoop ( ) throws InterruptedException { deltaCount = 0 ; deltaSize = 0 ; final long timeout = cleanupTimeout . get ( ) ; long ts = System . currentTimeMillis ( ) ; while ( true ) { final DisposableReference ref = ( DisposableReference ) refQueue . remove ( timeout ) ; if ( ref != null ) { if ( deltaCount == 0 ) { if ( vvverbose && cleanupThreadProcessing . get ( ) == false ) { logBusy ( ) ; } cleanupThreadProcessing . set ( true ) ; synchronized ( cleanupThreadProcessing ) { cleanupThreadProcessing . notifyAll ( ) ; } } deltaCount ++ ; deltaSize += ref . size ( ) ; /**
				 * Keep message coming even if we are continuously processing.
				 */ if ( vverbose && ( deltaCount % 10000 ) == 0 ) { sortGenerations ( ) ; logUsage ( ) ; } /*
				 * Means, we just finished processing
				 */ } else if ( deltaCount != 0 && ( System . currentTimeMillis ( ) - ts ) >= 1000 ) { ts = System . currentTimeMillis ( ) ; sortGenerations ( ) ; if ( verbose && deltaCount > 00 ) { logUsage ( ) ; } deltaCount = 0 ; deltaSize = 0 ; cleanupThreadProcessing . set ( false ) ; synchronized ( cleanupThreadProcessing ) { cleanupThreadProcessing . notifyAll ( ) ; } if ( vvverbose ) { logIdle ( ) ; } } if ( ref == null ) { if ( cleanupThreadActive . get ( ) ) { if ( memorySemaphore . hasQueuedThreads ( ) ) { invokeSystemGC ( ) ; } continue ; } else { if ( verbose ) { logFinished ( ) ; } break ; } } dispose ( ref ) ; } if ( verbose && deltaCount != 0 ) { System . out . printf ( "DisposableGC: disposed of %d entries [total=%dM]%n" , deltaCount , totalDisposed / 1000000 ) ; deltaCount = 0 ; } }
Drain ref queue loop.
Drain ref queue loop .
// We have a reference to dispose of // First one // Signal start // Signal finish // Null due to timeout