OpenHiva::HivaBufferPool

OpenHiva::HivaBufferPool is a class used to apply for OpenHiva::HivaBuffer. The definition is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class OpenHiva::HivaBufferPool {
public:
    HivaBufferPool();
    ~HivaBufferPool() = default;
    uint32_t InitMemoryPool(const std::string &poolName, const uint32_t blockSize, const uint32_t blockNum);
    void DestroyMemoryPool();
    uint32_t Allocate(HivaBuffer &hivaBuffer) const;         // Allocate the HivaBuffer from the memory pool.
private:
    mempool_t *pHandle_;
};

Pay attention to the following points when using HivaBufferPool:

  • You can use the constructor function of HivaBufferPool to transfer poolName (name of the memory pool), blockSize (size of the memory block, which is the same as the size of the Buff data area of HivaBuffer), and blockNum (number of memory blocks).
  • You can apply for a HivaBuffer from the memory pool by invoking the Allocate interface.