org.jnetpcap.nio
Class DisposableReference

java.lang.Object
  extended by java.lang.ref.Reference<T>
      extended by java.lang.ref.PhantomReference<java.lang.Object>
          extended by org.jnetpcap.nio.DisposableReference
All Implemented Interfaces:
Disposable, Link<DisposableReference>
Direct Known Subclasses:
JMemoryReference

public abstract class DisposableReference
extends java.lang.ref.PhantomReference<java.lang.Object>
implements Disposable, Link<DisposableReference>

A reference, who's data can be disposed of using dispose() method invokation. The Reference also implements the Link interface which allows the object to be used in a linked-list of DisposableReference objects managed by LinkSequence stored in global DisposableGC object.

DisposableReference extends WeakReference functionality by allowing DisposableGC to keep a hardreference to the reference (not the referant) to keep it in memory. Through the use of a ReferenceQueue, DisposableGC is notified when real objects (referants) are garbage collected. This class only keeps a weak reference to referants, but all cleanup information is also stored in subclass of this class. Specifically by calling on subclassed dispose() method, it allows the subclass to perform cleanup after an object, that has already been deleted from memory. For example JMemoryReference class, deallocates native memory, after the JMemory object that was using that native memory is already gone. The JMemoryReference remains as our subclass and has the address of native memory that needs to be reclaimed.

Author:
markbe

Constructor Summary
DisposableReference(java.lang.Object referant)
          Instantiates a new disposable reference.
 
Method Summary
 void dispose()
          Dispose.
 long getTs()
          Gets the ts.
 LinkSequence<DisposableReference> linkCollection()
          Link collection.
 void linkCollection(LinkSequence<DisposableReference> collection)
          Link collection.
 DisposableReference linkElement()
          Link element.
 Link<DisposableReference> linkNext()
          Link next.
 void linkNext(Link<DisposableReference> l)
          Link next.
 Link<DisposableReference> linkPrev()
          Link prev.
 void linkPrev(Link<DisposableReference> l)
          Link prev.
 void remove()
          Removes the.
 void setTs(long ts)
          Sets the ts.
 int size()
          Size.
 java.lang.String toString()
          To string.
 
Methods inherited from class java.lang.ref.PhantomReference
get
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DisposableReference

public DisposableReference(java.lang.Object referant)
Instantiates a new disposable reference.

Parameters:
referant - the referant
Method Detail

dispose

public void dispose()
Dispose.

Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

linkElement

public DisposableReference linkElement()
Link element.

Specified by:
linkElement in interface Link<DisposableReference>
Returns:
the disposable reference
See Also:
Link.linkElement()

linkCollection

public LinkSequence<DisposableReference> linkCollection()
Link collection.

Specified by:
linkCollection in interface Link<DisposableReference>
Returns:
the link sequence
See Also:
Link.linkCollection()

linkCollection

public void linkCollection(LinkSequence<DisposableReference> collection)
Link collection.

Specified by:
linkCollection in interface Link<DisposableReference>
Parameters:
collection - the collection
See Also:
Link.linkCollection(org.jnetpcap.nio.LinkSequence)

linkNext

public Link<DisposableReference> linkNext()
Link next.

Specified by:
linkNext in interface Link<DisposableReference>
Returns:
the link
See Also:
Link.linkNext()

linkNext

public void linkNext(Link<DisposableReference> l)
Link next.

Specified by:
linkNext in interface Link<DisposableReference>
Parameters:
l - the l
See Also:
Link.linkNext(org.jnetpcap.nio.Link)

linkPrev

public Link<DisposableReference> linkPrev()
Link prev.

Specified by:
linkPrev in interface Link<DisposableReference>
Returns:
the link
See Also:
Link.linkPrev()

linkPrev

public void linkPrev(Link<DisposableReference> l)
Link prev.

Specified by:
linkPrev in interface Link<DisposableReference>
Parameters:
l - the l
See Also:
Link.linkPrev(org.jnetpcap.nio.Link)

toString

public java.lang.String toString()
To string.

Overrides:
toString in class java.lang.Object
Returns:
the string
See Also:
Object.toString()

remove

public void remove()
Removes the.


size

public int size()
Size.

Returns:
the int

getTs

public long getTs()
Gets the ts.

Returns:
the ts

setTs

public void setTs(long ts)
Sets the ts.

Parameters:
ts - the ts to set