|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuka.util.IDConstants
uka.util.IDMap
uka.util.WeakIDMap
This class provides the same functionality as IDMap, but
uses weak references. Adding an object to this container does not
prevent it from being garbage collected. An identifier stays used until it is removed explicitly,
even if the corresponding object was garbage collected.
| Nested Class Summary | |
(package private) static class |
WeakIDMap.Ref
Weakly refer to an object, and remember its hash code beyond its death. |
| Field Summary | |
private java.lang.ref.ReferenceQueue |
queue
|
| Fields inherited from class uka.util.IDMap |
idToObject, INVALID_INDEX, space |
| Fields inherited from class uka.util.IDConstants |
FIRST_NEW_ID, FIRST_VALID_ID, INVALID_ID, UNUSED_ID |
| Constructor Summary | |
WeakIDMap()
|
|
WeakIDMap(IDSpace space)
|
|
| Method Summary | |
protected java.lang.Object |
get(int id)
|
protected int |
getIDForRef(WeakIDMap.Ref ref)
Find the identifier for a given reference. |
protected int |
getIndexForID(int id)
|
Iterator |
getObjects()
Specialized implementation for @T@IDMap.getObjects()
that prevents returning null values for already
garbage collected objects. |
Iterator |
getObjects(IntIterator ids)
|
private void |
initTransient()
|
int |
pollID()
Polls an internal ReferenceQueue for the next weakly
reacheable object and returns the identifier that was
associated with it. |
protected void |
restoreBeforeReadObject()
|
protected void |
set(int id,
java.lang.Object obj)
Access to the underlying IDMap.idToObject array is
encapsulated through the set(int, java.lang.Object) and get(int)
methods. |
int |
waitForID()
Wait until an object that is referenced from this map becomes weakly reacheable and return its identifier. |
int |
waitForID(long timeout)
Wait at most timeout milliseconds until an object
that is referenced from this map becomes weakly reacheable and
return its identifier. |
| Methods inherited from class uka.util.IDMap |
appendTo, clear, dump, findID, getHash, getID, getIndexForHash, getObject, getSize, getUsedIDs, isUsed, rawFindID, remove, resetObject, setObject |
| Methods inherited from class uka.util.IDConstants |
isNew, isValid, normalizeID, toggleNew |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private transient java.lang.ref.ReferenceQueue queue
| Constructor Detail |
public WeakIDMap()
public WeakIDMap(IDSpace space)
| Method Detail |
private void initTransient()
protected void set(int id,
java.lang.Object obj)
IDMapIDMap.idToObject array is
encapsulated through the IDMap.set(int, java.lang.Object) and IDMap.get(int)
methods. Subclasses may use this hooks to add functionality
whenever an object is stored or retrieved.
set in class IDMapprotected java.lang.Object get(int id)
get in class IDMapIDMap.set(int, java.lang.Object)protected int getIndexForID(int id)
getIndexForID in class IDMappublic Iterator getObjects()
@T@IDMap.getObjects()
that prevents returning null values for already
garbage collected objects.
getObjects in class IDMappublic Iterator getObjects(IntIterator ids)
null value in the output sequence.public int pollID()
ReferenceQueue for the next weakly
reacheable object and returns the identifier that was
associated with it. If there is no more weakly reacheable
object, the method returns IDConstants.INVALID_ID.
public int waitForID()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpollID(),
ReferenceQueue.remove()
public int waitForID(long timeout)
throws java.lang.InterruptedException
timeout milliseconds until an object
that is referenced from this map becomes weakly reacheable and
return its identifier. If no object becomes unreferenced within
timeout, IDConstants.INVALID_ID is returned.
java.lang.InterruptedExceptionpollID(),
ReferenceQueue.remove(long)protected int getIDForRef(WeakIDMap.Ref ref)
IDConstants.INVALID_ID is returned.
IDMap.rawFindID(java.lang.Object, int)
protected void restoreBeforeReadObject()
throws java.lang.ClassNotFoundException,
java.io.IOException
restoreBeforeReadObject in class IDMapjava.lang.ClassNotFoundException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||