org.activemath.omdocjdom
Class SimplePool

java.lang.Object
  extended by org.activemath.omdocjdom.SimplePool
Direct Known Subclasses:
SimplePoolPassive

public class SimplePool
extends Object

Simple pool class with objects that have a life and death.

Version:

Nested Class Summary
static interface SimplePool.Poolable
           
static interface SimplePool.PoolableFactory
           
 
Field Summary
protected  int baseNum
           
protected  SimplePool.PoolableFactory factory
           
protected  SimplePool.Poolable lastFinished
           
protected  List poolables
           
 
Constructor Summary
protected SimplePool()
           
  SimplePool(SimplePool.PoolableFactory factory, int size)
           
 
Method Summary
 void destroy(long timeout)
          Waits until they're all finished for timeout miliseconds then destroys them all.
 SimplePool.Poolable getAFreeOne()
          Searches a free one waiting eternally, returns null if the thread was interrupted.
 SimplePool.Poolable getAFreeOne(int timeout, int interval)
           
protected  SimplePool.Poolable getAFreeOneInternal()
           
 void justStart(SimplePool.Poolable poolable)
           
 void use(SimplePool.Poolable poolable)
          Currently does nothing but call the SimplePool.Poolable.run() but may, in the future, have a better freeness-flag modification.
 boolean waitTillAllFinished(long timeout, int interval)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected SimplePool.PoolableFactory factory

baseNum

protected int baseNum

poolables

protected List poolables

lastFinished

protected SimplePool.Poolable lastFinished
Constructor Detail

SimplePool

public SimplePool(SimplePool.PoolableFactory factory,
                  int size)

SimplePool

protected SimplePool()
Method Detail

getAFreeOne

public SimplePool.Poolable getAFreeOne(int timeout,
                                       int interval)
                                throws InterruptedException
Throws:
InterruptedException

getAFreeOne

public SimplePool.Poolable getAFreeOne()
Searches a free one waiting eternally, returns null if the thread was interrupted.


getAFreeOneInternal

protected SimplePool.Poolable getAFreeOneInternal()

use

public void use(SimplePool.Poolable poolable)
Currently does nothing but call the SimplePool.Poolable.run() but may, in the future, have a better freeness-flag modification.


justStart

public void justStart(SimplePool.Poolable poolable)

waitTillAllFinished

public boolean waitTillAllFinished(long timeout,
                                   int interval)

destroy

public void destroy(long timeout)
Waits until they're all finished for timeout miliseconds then destroys them all. Invokes the destroy method in a new thread.