public class DeflaterPool
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
_capacity |
private int |
_compressionLevel |
private boolean |
_nowrap |
private java.util.concurrent.atomic.AtomicInteger |
_numDeflaters |
private java.util.Queue<java.util.zip.Deflater> |
_pool |
Constructor and Description |
---|
DeflaterPool(int capacity,
int compressionLevel,
boolean nowrap)
Create a Pool of
Deflater instances. |
Modifier and Type | Method and Description |
---|---|
java.util.zip.Deflater |
acquire() |
protected java.util.zip.Deflater |
newDeflater() |
void |
release(java.util.zip.Deflater deflater) |
private final java.util.Queue<java.util.zip.Deflater> _pool
private final int _compressionLevel
private final boolean _nowrap
private final java.util.concurrent.atomic.AtomicInteger _numDeflaters
private final int _capacity
public DeflaterPool(int capacity, int compressionLevel, boolean nowrap)
Deflater
instances.
If given a capacity equal to zero the Deflaters will not be pooled
and will be created on acquire and ended on release.
If given a negative capacity equal to zero there will be no size restrictions on the DeflaterPoolcapacity
- maximum number of Deflaters which can be contained in the poolcompressionLevel
- the default compression level for new Deflater objectsnowrap
- if true then use GZIP compatible compression for all new Deflater objectsprotected java.util.zip.Deflater newDeflater()
public java.util.zip.Deflater acquire()
public void release(java.util.zip.Deflater deflater)
deflater
- returns this Deflater to the pool or calls deflater.end() if the pool is full.