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_