이 파일의 문서화 페이지로 가기
27 #ifndef _AKPOOLALLOCATOR_H
28 #define _AKPOOLALLOCATOR_H
36 #define AK_OBJECT_POOL_EXTRA_SAFETY
38 namespace UnitTest {
struct ObjectPoolHelper; }
42 template<AkMemID T_MEMID = AkMemID_Object>
47 inline static constexpr
void Lock() {}
48 inline static constexpr
void Unlock() {}
73 using AllocatorType::AllocatorType;
86 AKASSERT(!m_data &&
"ObjectPool is already initialized, call 'Term' before calling 'Init' again");
87 AKASSERT(count &&
"ObjectPool count must be greater than zero");
93 m_data =
reinterpret_cast<DataType*
>(AllocatorType::Alloc(count *
sizeof(
DataType)));
103 for (
SizeType i = 0; i < m_capacity - 1; i++)
104 m_data[i].next = i + 1;
114 AKASSERT(m_size == 0 &&
"Can't call Term() when some objects are still allocated");
141 DataType& data = m_data[m_freeList];
142 m_freeList = data.
next;
166 AKASSERT(data &&
"Deallocating null data");
170 AKASSERT((tdata >= m_data && tdata < m_data + m_capacity) &&
"Pointer address out of range");
171 if (tdata < m_data || tdata >= m_data + m_capacity)
175 AKASSERT(m_size &&
"Trying to deallocate when empty");
177 #ifdef AK_OBJECT_POOL_EXTRA_SAFETY
181 tdata->
next = m_freeList;
182 m_freeList = (
SizeType)(tdata - m_data);
192 for (
SizeType i = 0; i < m_capacity - 1; i++)
193 m_data[i].next = i + 1;
201 DataType* m_data =
nullptr;
208 inline bool IsAllocated(
SizeType index)
const
Definition of data structures for AkAudioObject
static constexpr SizeType kInvalidIndex
static constexpr void Unlock()
AKSOUNDENGINE_API void Free(AkMemPoolId in_poolId, void *in_pMemAddress)
AKRESULT
Standard function call result.
AK_NODISCARD ValueType * AllocateZeroFilled()
Initialize memory before returning.
AK_NODISCARD bool IsFull() const
AKRESULT Init(SizeType count)
@ AK_Success
The operation was successful.
ObjectPool(ObjectPool &&)=delete
@ AK_InvalidParameter
Something is not within bounds, check the documentation of the function returning this code.
AK_NODISCARD bool IsEmpty() const
uint8_t data[sizeof(ValueType)]
friend struct UnitTest::ObjectPoolHelper
#define AKASSERT(Condition)
AK_NODISCARD ValueType * Allocate()
AKRESULT Deallocate(ValueType *data)
AK_NODISCARD SizeType Size() const
ObjectPool(const ObjectPool &)=delete
AK_NODISCARD SizeType Capacity() const
ObjectPool & operator=(const ObjectPool &)=delete
ObjectPool & operator=(ObjectPool &&)=delete
An object pool of N reusable objects with one allocation.
uint32_t AkUInt32
Unsigned 32-bit integer
static constexpr void Lock()
@ AK_InsufficientMemory
Memory error.
AkForceInline void AkMemSet(void *pDest, AkInt32 iVal, AkUInt32 uSize)
const ValueType & Data() const
지원이 필요하신가요?
질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!
지원 페이지를 방문해 주세요
작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.
프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.
Wwise를 시작해 보세요