public class TParserPool extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
TParserPool.ParserFunction<T>
Functional interface for parser operations.
|
static class |
TParserPool.PoolStatistics
Pool statistics for monitoring.
|
static class |
TParserPool.TimeoutException
Custom exception for timeout scenarios.
|
| Constructor and Description |
|---|
TParserPool()
Creates a parser pool with default size
|
TParserPool(int poolSize)
Creates a parser pool with specified size
|
| Modifier and Type | Method and Description |
|---|---|
TGSqlParser |
borrowParser(EDbVendor vendor)
Borrows a parser from the pool for the specified vendor.
|
TParserPool.PoolStatistics |
getStatistics(EDbVendor vendor)
Gets pool statistics for monitoring.
|
void |
prewarm(EDbVendor vendor,
int count)
Pre-warms the pool by creating parsers in advance.
|
void |
returnParser(EDbVendor vendor,
TGSqlParser parser)
Returns a parser to the pool for reuse.
|
void |
shutdown()
Shuts down the pool and clears all parsers.
|
<T> T |
withParser(EDbVendor vendor,
TParserPool.ParserFunction<T> function)
Executes a function with a borrowed parser and automatically returns it.
|
public TParserPool()
public TParserPool(int poolSize)
poolSize - Size of the pool for each vendorpublic TGSqlParser borrowParser(EDbVendor vendor) throws InterruptedException
vendor - Database vendorInterruptedException - if interrupted while waitingpublic void returnParser(EDbVendor vendor, TGSqlParser parser)
vendor - Database vendorparser - Parser instance to returnpublic <T> T withParser(EDbVendor vendor, TParserPool.ParserFunction<T> function) throws Exception
vendor - Database vendorfunction - Function to execute with the parserExceptionpublic TParserPool.PoolStatistics getStatistics(EDbVendor vendor)
public void prewarm(EDbVendor vendor, int count)
vendor - Database vendorcount - Number of parsers to pre-create (up to poolSize)public void shutdown()