ArmNN
 20.05
RefMemoryManager::Pool Class Reference

#include <RefMemoryManager.hpp>

Public Member Functions

 Pool (unsigned int numBytes)
 
 ~Pool ()
 
void Acquire ()
 
void Release ()
 
void * GetPointer ()
 
void Reserve (unsigned int numBytes)
 

Detailed Description

Definition at line 33 of file RefMemoryManager.hpp.

Constructor & Destructor Documentation

◆ Pool()

Pool ( unsigned int  numBytes)

Definition at line 63 of file RefMemoryManager.cpp.

64  : m_Size(numBytes),
65  m_Pointer(nullptr)
66 {}

◆ ~Pool()

~Pool ( )

Definition at line 68 of file RefMemoryManager.cpp.

References RefMemoryManager::Pool::Release().

69 {
70  if (m_Pointer)
71  {
72  Release();
73  }
74 }

Member Function Documentation

◆ Acquire()

void Acquire ( )

Definition at line 88 of file RefMemoryManager.cpp.

References ARMNN_ASSERT_MSG.

89 {
90  ARMNN_ASSERT_MSG(!m_Pointer, "RefMemoryManager::Pool::Acquire() called when memory already acquired");
91  m_Pointer = ::operator new(size_t(m_Size));
92 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ GetPointer()

void * GetPointer ( )

Definition at line 76 of file RefMemoryManager.cpp.

References ARMNN_ASSERT_MSG.

Referenced by RefMemoryManager::GetPointer().

77 {
78  ARMNN_ASSERT_MSG(m_Pointer, "RefMemoryManager::Pool::GetPointer() called when memory not acquired");
79  return m_Pointer;
80 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ Release()

void Release ( )

Definition at line 94 of file RefMemoryManager.cpp.

References ARMNN_ASSERT_MSG.

Referenced by RefMemoryManager::Pool::~Pool().

95 {
96  ARMNN_ASSERT_MSG(m_Pointer, "RefMemoryManager::Pool::Release() called when memory not acquired");
97  ::operator delete(m_Pointer);
98  m_Pointer = nullptr;
99 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

◆ Reserve()

void Reserve ( unsigned int  numBytes)

Definition at line 82 of file RefMemoryManager.cpp.

References ARMNN_ASSERT_MSG.

Referenced by RefMemoryManager::Manage().

83 {
84  ARMNN_ASSERT_MSG(!m_Pointer, "RefMemoryManager::Pool::Reserve() cannot be called after memory acquired");
85  m_Size = std::max(m_Size, numBytes);
86 }
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15

The documentation for this class was generated from the following files: