이 파일의 문서화 페이지로 가기
27 #ifndef _AKPOOLALLOCATOR_H
28 #define _AKPOOLALLOCATOR_H
36 #define AK_OBJECT_POOL_EXTRA_SAFETY
39 namespace UnitTest {
struct ObjectPoolHelper; }
44 template<AkMemID T_MEMID = AkMemID_Object>
49 inline static constexpr
void Lock() {}
50 inline static constexpr
void Unlock() {}
75 using AllocatorType::AllocatorType;
88 AKASSERT(!m_data &&
"ObjectPool is already initialized, call 'Term' before calling 'Init' again");
89 AKASSERT(count &&
"ObjectPool count must be greater than zero");
95 m_data =
reinterpret_cast<DataType*
>(AllocatorType::Alloc(count *
sizeof(
DataType)));
105 for (
SizeType i = 0; i < m_capacity - 1; i++)
106 m_data[i].next = i + 1;
116 AKASSERT(m_size == 0 &&
"Can't call Term() when some objects are still allocated");
143 DataType& data = m_data[m_freeList];
144 m_freeList = data.
next;
168 AKASSERT(data &&
"Deallocating null data");
172 AKASSERT((tdata >= m_data && tdata < m_data + m_capacity) &&
"Pointer address out of range");
173 if (tdata < m_data || tdata >= m_data + m_capacity)
177 AKASSERT(m_size &&
"Trying to deallocate when empty");
179 #ifdef AK_OBJECT_POOL_EXTRA_SAFETY
183 tdata->
next = m_freeList;
184 m_freeList = (
SizeType)(tdata - m_data);
194 for (
SizeType i = 0; i < m_capacity - 1; i++)
195 m_data[i].next = i + 1;
203 DataType* m_data =
nullptr;
210 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)
AK_NODISCARD ValueType * AllocateZeroFilled()
Initialize memory before returning.
AK_NODISCARD bool IsFull() const
AKRESULT Init(SizeType count)
ObjectPool(ObjectPool &&)=delete
AK_NODISCARD bool IsEmpty() const
uint8_t data[sizeof(ValueType)]
friend struct UnitTest::ObjectPoolHelper
#define AKASSERT(Condition)
AK_NODISCARD ValueType * Allocate()
@ AK_InsufficientMemory
Memory error.
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.
@ AK_InvalidParameter
Something is not within bounds, check the documentation of the function returning this code.
uint32_t AkUInt32
Unsigned 32-bit integer
static constexpr void Lock()
@ AK_Success
The operation was successful.
AkForceInline void AkMemSet(void *pDest, AkInt32 iVal, AkUInt32 uSize)
const ValueType & Data() const
지원이 필요하신가요?
질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!
지원 페이지를 방문해 주세요
작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.
프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.
Wwise를 시작해 보세요