6 #include "armnnTestUtils/MockMemoryManager.hpp"
11 MockMemoryManager::MockMemoryManager()
14 MockMemoryManager::~MockMemoryManager()
17 MockMemoryManager::Pool* MockMemoryManager::Manage(
unsigned int numBytes)
19 if (!m_FreePools.empty())
21 Pool* res = m_FreePools.back();
22 m_FreePools.pop_back();
23 res->Reserve(numBytes);
28 m_Pools.push_front(Pool(numBytes));
29 return &m_Pools.front();
33 void MockMemoryManager::Allocate(MockMemoryManager::Pool* pool)
35 m_FreePools.push_back(pool);
38 void* MockMemoryManager::GetPointer(MockMemoryManager::Pool* pool)
40 return pool->GetPointer();
43 void MockMemoryManager::Acquire()
45 for (Pool& pool : m_Pools)
51 void MockMemoryManager::Release()
53 for (Pool& pool : m_Pools)
59 MockMemoryManager::Pool::Pool(
unsigned int numBytes)
64 MockMemoryManager::Pool::~Pool()
72 void* MockMemoryManager::Pool::GetPointer()
77 void MockMemoryManager::Pool::Reserve(
unsigned int numBytes)
79 m_Size = std::max(m_Size, numBytes);
82 void MockMemoryManager::Pool::Acquire()
84 m_Pointer = ::operator
new(size_t(m_Size));
87 void MockMemoryManager::Pool::Release()
89 ::operator
delete(m_Pointer);