21 #ifndef INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_
22 #define INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_
25 #include <ola/io/MemoryBlock.h>
37 : m_block_size(block_size),
38 m_blocks_allocated(0) {
47 if (m_free_blocks.empty()) {
48 uint8_t* data =
new uint8_t[m_block_size];
49 OLA_DEBUG <<
"new block allocated at @" <<
reinterpret_cast<int*
>(data);
65 m_free_blocks.push(block);
69 unsigned int FreeBlocks()
const {
70 return static_cast<unsigned int>(m_free_blocks.size());
79 void Purge(
unsigned int remaining) {
80 while (m_free_blocks.size() != remaining) {
88 unsigned int BlocksAllocated()
const {
return m_blocks_allocated; }
91 static const unsigned int DEFAULT_BLOCK_SIZE = 1024;
94 std::queue<MemoryBlock*> m_free_blocks;
95 const unsigned int m_block_size;
96 unsigned int m_blocks_allocated;
100 #endif // INCLUDE_OLA_IO_MEMORYBLOCKPOOL_H_