21 #ifndef INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_ 22 #define INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_ 38 : m_block_size(block_size),
39 m_blocks_allocated(0) {
48 if (m_free_blocks.empty()) {
49 uint8_t* data =
new uint8_t[m_block_size];
50 OLA_DEBUG <<
"new block allocated at @" <<
reinterpret_cast<int*
>(data);
66 m_free_blocks.push(block);
70 unsigned int FreeBlocks()
const {
71 return static_cast<unsigned int>(m_free_blocks.size());
80 void Purge(
unsigned int remaining) {
81 while (m_free_blocks.size() != remaining) {
89 unsigned int BlocksAllocated()
const {
return m_blocks_allocated; }
92 static const unsigned int DEFAULT_BLOCK_SIZE = 1024;
95 std::queue<MemoryBlock*> m_free_blocks;
96 const unsigned int m_block_size;
97 unsigned int m_blocks_allocated;
101 #endif // INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_
#define OLA_DEBUG
Definition: Logging.h:91
A MemoryBlock encapsulates a chunk of memory. It's used by the IOQueue and IOStack classes...
Definition: MemoryBlock.h:41
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Header file for OLA Logging.
MemoryBlockPool. This class is not thread safe.
Definition: MemoryBlockPool.h:35