Package com.caucho.hessian.util
Class HessianFreeList<T>
java.lang.Object
com.caucho.hessian.util.HessianFreeList<T>
FreeList provides a simple class to manage free objects. This is useful
for large data structures that otherwise would gobble up huge GC time.
The free list is bounded. Freeing an object when the list is full will do nothing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate()
Try to get an object from the free list.boolean
boolean
checkDuplicate
(T obj) Debugging to see if the object has already been freed.boolean
Frees the object.void
freeCareful
(T obj) Frees the object.
-
Constructor Details
-
HessianFreeList
public HessianFreeList(int size) Create a new free list.- Parameters:
initialSize
- maximum number of free objects to store.
-
-
Method Details
-
allocate
Try to get an object from the free list. Returns null if the free list is empty.- Returns:
- the new object or null.
-
free
Frees the object. If the free list is full, the object will be garbage collected.- Parameters:
obj
- the object to be freed.
-
allowFree
-
freeCareful
Frees the object. If the free list is full, the object will be garbage collected.- Parameters:
obj
- the object to be freed.
-
checkDuplicate
Debugging to see if the object has already been freed.
-