Package org.snmp4j.security
Class CipherPool
java.lang.Object
org.snmp4j.security.CipherPool
The CipherPool class provides service to share and reuse Cipher instances, across
different threads. The maximum number of Ciphers in the pool might temporarily
exceed the
maxPoolSize
to minimize waiting time.- Since:
- 2.2.2
- Author:
- Frank Fock
-
Constructor Summary
ConstructorDescriptionCreates a new cipher pool with a pool size ofRuntime.availableProcessors()
.CipherPool
(int maxPoolSize) Creates a new cipher pool with a given pool size. -
Method Summary
Modifier and TypeMethodDescriptionint
void
offerCipher
(Cipher cipher) Offers a Cipher to the pool (thus returns it to the pool).Gets a Cipher from the pool.
-
Constructor Details
-
CipherPool
public CipherPool()Creates a new cipher pool with a pool size ofRuntime.availableProcessors()
. -
CipherPool
public CipherPool(int maxPoolSize) Creates a new cipher pool with a given pool size.- Parameters:
maxPoolSize
- the maximum number of ciphers in the pool.
-
-
Method Details
-
getMaxPoolSize
public int getMaxPoolSize() -
reuseCipher
Gets a Cipher from the pool. It must be returned to the pool by callingofferCipher(Cipher)
when one of itsCipher.doFinal()
methods have been called and it is not needed anymore.- Returns:
- a Cipher from the pool, or
null
if the pool currently does not contain any cipher.
-
offerCipher
Offers a Cipher to the pool (thus returns it to the pool).- Parameters:
cipher
- a Cipher instance previously acquired byreuseCipher()
or created externally.
-