Module org.snmp4j

Class CipherPool

java.lang.Object
org.snmp4j.security.CipherPool

public class CipherPool extends Object
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 Details

    • CipherPool

      public CipherPool()
      Creates a new cipher pool with a pool size of Runtime.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

      public Cipher reuseCipher()
      Gets a Cipher from the pool. It must be returned to the pool by calling offerCipher(Cipher) when one of its Cipher.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

      public void offerCipher(Cipher cipher)
      Offers a Cipher to the pool (thus returns it to the pool).
      Parameters:
      cipher - a Cipher instance previously acquired by reuseCipher() or created externally.