|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.uima.util.CasPool
public class CasPool
This class represents a simple pool of CAS
instances. This is useful for multithreaded
applications, where there is a need for multiple CASes to be processed simultaneously. Because
CAS creation is expensive, it is a good idea to create a pool of reusable CAS instances at
initialization time, rather than creating a new CAS each time one is needed.
Clients check-out CAS instances from the pool using the getCas()
method and check-in CAS
instances using the releaseCas(CAS)
method.
Constructor Summary | |
---|---|
CasPool(int aNumInstances,
AnalysisEngine aAnalysisEngine)
Creates a new CasPool |
|
CasPool(int aNumInstances,
CasDefinition aCasDefinition,
Properties aPerformanceTuningSettings)
Creates a new CasPool. |
|
CasPool(int aNumInstances,
CasManager aCasManager,
Properties aPerformanceTuningSettings)
Creates a new CasPool |
|
CasPool(int aNumInstances,
Collection<? extends ProcessingResourceMetaData> aCollectionOfProcessingResourceMetaData,
Properties aPerformanceTuningSettings,
ResourceManager aResourceManager)
Creates a new CasPool |
|
CasPool(int aNumInstances,
ProcessingResourceMetaData aMetaData)
Creates a new CasPool |
|
CasPool(int aNumInstances,
ProcessingResourceMetaData aMetaData,
ResourceManager aResourceManager)
Creates a new CasPool |
Method Summary | |
---|---|
protected Vector<CAS> |
getAllInstances()
|
CAS |
getCas()
Checks out a CAS from the pool. |
CAS |
getCas(long aTimeout)
Checks out a CAS from the pool. |
protected Vector<CAS> |
getFreeInstances()
|
int |
getNumAvailable()
Gets the number of CASes currently available in this pool. |
int |
getSize()
Gets the size of this pool (the total number of CAS instances that it can hold). |
void |
releaseCas(CAS aCas)
Checks in a CAS to the pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CasPool(int aNumInstances, Collection<? extends ProcessingResourceMetaData> aCollectionOfProcessingResourceMetaData, Properties aPerformanceTuningSettings, ResourceManager aResourceManager) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaCollectionOfProcessingResourceMetaData
- a collection of
ProcessingResourceMetaData
objects.aPerformanceTuningSettings
- Properties object containing framework performance tuning settings using key names
defined on UIMAFramework
interfaceaResourceManager
- the resource manager to use to resolve import declarations within the metadata
ResourceInitializationException
- if the CAS instances could not be createdpublic CasPool(int aNumInstances, AnalysisEngine aAnalysisEngine) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaAnalysisEngine
- the analysis engine that will create the CAS instances and which will later be used to
process them
ResourceInitializationException
- if the CAS instances could not be createdpublic CasPool(int aNumInstances, ProcessingResourceMetaData aMetaData) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaMetaData
- metadata that includes the type system for the CAS
ResourceInitializationException
- if the CAS instances could not be createdpublic CasPool(int aNumInstances, ProcessingResourceMetaData aMetaData, ResourceManager aResourceManager) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaMetaData
- metadata that includes the type system for the CAS
ResourceInitializationException
- if the CAS instances could not be createdpublic CasPool(int aNumInstances, CasDefinition aCasDefinition, Properties aPerformanceTuningSettings) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaCasDefinition
- the Cas definition, which includes the type system, type priorities, and indexes for
the CASes in the pool.aPerformanceTuningSettings
- Properties object containing framework performance tuning settings using key names
defined on UIMAFramework
interface
ResourceInitializationException
public CasPool(int aNumInstances, CasManager aCasManager, Properties aPerformanceTuningSettings) throws ResourceInitializationException
aNumInstances
- the number of CAS instances in the poolaCasManager
- CAS Manager that will be used to create the CAS. The CAS Manager
holds the CAS Definition. Also all CASes created from the same
CAS Manager will share identical TypeSystem objects.aPerformanceTuningSettings
- Properties object containing framework performance tuning settings using key names
defined on UIMAFramework
interface
ResourceInitializationException
Method Detail |
---|
public CAS getCas()
null
if none are available (in which case the
client may Object.wait()
on this object in order to be notified when an
instance becomes available).public void releaseCas(CAS aCas)
CAS.reset()
method, to ensure
that when the CAS is later retrieved from the pool it will be ready to use. Also notifies other
Threads that may be waiting for an instance to become available.
aCas
- the Cas to releasepublic CAS getCas(long aTimeout)
aTimeout
- the time to wait in milliseconds. A value of <=0 will wait forever.
null
if none are available within the specified
timeout period.public int getSize()
public int getNumAvailable()
protected Vector<CAS> getAllInstances()
protected Vector<CAS> getFreeInstances()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |