org.webmacro.util
Class UPool

java.lang.Object
  |
  +--org.webmacro.util.UPool
All Implemented Interfaces:
Pool

public final class UPool
extends java.lang.Object
implements Pool

This is an unsynchronized object pool. It does synchronize on the objects added to and removed from the pool but it never synchronizes on its own data structures. As a result a null may be returned from the pool when an object actually exists (rare case), but an object is still guaranteed to be returned to only one thread.


Constructor Summary
UPool(int size)
          Create a new Pool.
 
Method Summary
 java.lang.Object get()
          Get an item from the pool
 void put(java.lang.Object o)
          Add an item to the pool for later re-use
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UPool

public UPool(int size)
Create a new Pool. Size is the logarithm of the number of slots in the pool. A size 4 pool has 16 spaces, a size 5 pool has 32, a size 6 pool has 64, and so on.
Method Detail

put

public void put(java.lang.Object o)
Add an item to the pool for later re-use
Specified by:
put in interface Pool

get

public java.lang.Object get()
Get an item from the pool
Specified by:
get in interface Pool