com.caucho.util
Class FreeRingDual<T>

java.lang.Object
  extended by com.caucho.util.FreeRingDual<T>

public final class FreeRingDual<T>
extends java.lang.Object

A free list with soft references.


Constructor Summary
FreeRingDual(int capacity, int softCapacity)
          Create a new free list.
 
Method Summary
 T allocate()
          Try to get an object from the free list.
 boolean checkDuplicate(T obj)
          Debugging to see if the object has already been freed.
 boolean free(T value)
          Frees the object.
 boolean freeCareful(T value)
          Frees the object.
 long getHead()
           
 long getHeadAlloc()
           
 int getSize()
           
 long getTail()
           
 long getTailAlloc()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeRingDual

public FreeRingDual(int capacity,
                    int softCapacity)
Create a new free list.

Parameters:
initialSize - maximum number of free objects to store.
Method Detail

getSize

public int getSize()

getHead

public long getHead()

getHeadAlloc

public long getHeadAlloc()

getTail

public long getTail()

getTailAlloc

public long getTailAlloc()

allocate

public T 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

public boolean free(T value)
Frees the object. If the free list is full, the object will be garbage collected.

Parameters:
obj - the object to be freed.

freeCareful

public boolean freeCareful(T value)
Frees the object. If the free list is full, the object will be garbage collected.

Parameters:
obj - the object to be freed.

checkDuplicate

public boolean checkDuplicate(T obj)
Debugging to see if the object has already been freed.