jist.runtime
Class Pool.ArrayPool

java.lang.Object
  extended by jist.runtime.Pool
      extended by jist.runtime.Pool.ArrayPool
Enclosing class:
Pool

public static class Pool.ArrayPool
extends Pool

Implements an object pool for the massively used Object array objects. Note that, for performance reasons, this class is intentionally NOT thread-safe.

Since:
JIST1.0
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from class jist.runtime.Pool
Pool.ArrayPool, Pool.ContinuationPool, Pool.EventPool
 
Field Summary
private  int count
          Index into array pool.
private  java.lang.Object[][] pool
          Private array pool of Object arrays of size 'size'.
private  int size
          Size of Object arrays pooled.
 
Constructor Summary
Pool.ArrayPool(int arraysize, int poolsize)
          Create new object array pool of given size, for array of given size.
 
Method Summary
 java.lang.Object[] get()
          Return an array from the pool, or create a new one if pool is empty.
static void main(java.lang.String[] args)
          Small program to test performance of ArrayPool implementation.
 void put(java.lang.Object[] o)
          Place a free (otherwise unused) array object back in the pool, if there is space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

private final int size
Size of Object arrays pooled.


pool

private final java.lang.Object[][] pool
Private array pool of Object arrays of size 'size'.


count

private int count
Index into array pool.

Constructor Detail

Pool.ArrayPool

public Pool.ArrayPool(int arraysize,
                      int poolsize)
Create new object array pool of given size, for array of given size.

Parameters:
arraysize - object array size pooled
poolsize - size of object array pool
Method Detail

get

public java.lang.Object[] get()
Return an array from the pool, or create a new one if pool is empty.

Returns:
initialized Object array

put

public void put(java.lang.Object[] o)
Place a free (otherwise unused) array object back in the pool, if there is space. Remember to any clear reference from the array to allow garbage collection to occur.

Parameters:
o - reference to free array object

main

public static void main(java.lang.String[] args)
Small program to test performance of ArrayPool implementation.

Parameters:
args - command line parameters