20template <
size_t BS,
size_t NB>
70template <
size_t BS,
size_t NB>
73 assert(m_pool ==
NULL);
75 assert(m_blockRef.Size());
77 m_pool =
new MxU8[GetPoolSize() * m_blockSize * 1024];
83template <
size_t BS,
size_t NB>
86 assert(m_pool !=
NULL);
88 assert(m_blockRef.Size());
90 for (
MxU32 i = 0; i < GetPoolSize(); i++) {
94 MxTrace(
"Get> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.Count());
96 return &m_pool[i * m_blockSize * 1024];
103template <
size_t BS,
size_t NB>
106 assert(m_pool !=
NULL);
108 assert(m_blockRef.Size());
110 MxU32 i = (
MxU32) (p_buf - m_pool) / (m_blockSize * 1024);
112 assert(i >= 0 && i < GetPoolSize());
113 assert(m_blockRef[i]);
116 m_blockRef[i].Flip();
119 MxTrace(
"Release> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.Count());
Templated fixed-size bitset for bit manipulation.
MxU32 Size() const
Returns the number of bits (N) this bitset manages.
[AI] Fixed-size memory pool template for fast allocation and deallocation.
MxMemoryPool()
[AI] Constructor.
MxResult Allocate()
[AI] Allocates the memory pool according to template parameters.
void Release(MxU8 *p_buf)
[AI] Releases the block at the given pointer back into the pool.
MxU8 * Get()
[AI] Gets a pointer to the next available block in the memory pool.
~MxMemoryPool()
[AI] Destructor.
MxU32 GetPoolSize() const
[AI] Returns the number of blocks in the pool.
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
#define MxTrace(args)
[AI] Macro for trace logging (non-variadic version, MSVC compatibility), expands to nothing.