public class CipherPool extends Object
maxPoolSize
to minimize waiting time.Constructor and Description |
---|
CipherPool()
Creates a new cipher pool with a pool size of
Runtime.availableProcessors() . |
CipherPool(int maxPoolSize)
Creates a new cipher pool with a given pool size.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxPoolSize() |
void |
offerCipher(Cipher cipher)
Offers a Cipher to the pool (thus returns it to the pool).
|
Cipher |
reuseCipher()
Gets a Cipher from the pool.
|
public CipherPool()
Runtime.availableProcessors()
.public CipherPool(int maxPoolSize)
maxPoolSize
- the maximum number of ciphers in the pool.public int getMaxPoolSize()
public Cipher reuseCipher() throws NoSuchPaddingException, NoSuchAlgorithmException
offerCipher(Cipher)
when one of its Cipher.doFinal()
methods have been called and it is not needed anymore.null
if the pool currently does not contain any
cipher.NoSuchPaddingException
NoSuchAlgorithmException
public void offerCipher(Cipher cipher)
cipher
- a Cipher instance previously acquired by reuseCipher()
or created externally.Copyright © 2016 SNMP4J.org. All rights reserved.