Package org.htmlunit
Class WebClient.CSS3ParserPool
- java.lang.Object
-
- org.htmlunit.WebClient.CSS3ParserPool
-
- Enclosing class:
- WebClient
static class WebClient.CSS3ParserPool extends java.lang.Object
Our pool of CSS3Parsers. If you need a parser, get it from here and use the AutoCloseable functionality with a try-with-resource block. If you don't want to do that at all, continue to build CSS3Parsers the old fashioned way. Fetching a parser is thread safe. This API is built to minimize synchronization overhead, hence it is possible to miss a returned parser from another thread under heavy pressure, but because that is unlikely, we keep it simple and efficient. Caches are not supposed to give cutting-edge guarantees. This concept avoids a resource leak when someone does not close the fetched parser because the pool does not know anything about the parser unless it returns. We are not running a checkout-checkin concept. INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentLinkedDeque<WebClient.PooledCSS3Parser>
parsers_
-
Constructor Summary
Constructors Constructor Description CSS3ParserPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebClient.PooledCSS3Parser
get()
Fetch a new or recycled CSS3parser.protected void
recycle(WebClient.PooledCSS3Parser parser)
Return a parser.
-
-
-
Field Detail
-
parsers_
private java.util.concurrent.ConcurrentLinkedDeque<WebClient.PooledCSS3Parser> parsers_
-
-
Method Detail
-
get
public WebClient.PooledCSS3Parser get()
Fetch a new or recycled CSS3parser. Make sure you use the try-with-resource concept to automatically return it after use because a parser creation is expensive. We won't get a leak, if you don't do so, but that will remove the advantage.- Returns:
- a parser
-
recycle
protected void recycle(WebClient.PooledCSS3Parser parser)
Return a parser. Normally you don't have to use that method explicitly. Prefer to user the AutoCloseable interface of the PooledParser by using a try-with-resource statement.- Parameters:
parser
- the parser to recycle
-
-