이 파일의 문서화 페이지로 가기
27 #ifndef _AKBLOCKPOOL_H
28 #define _AKBLOCKPOOL_H
41 #define AK_DYNA_BLK_SCRUB_MEM
44 #ifdef AK_DYNA_BLK_STATS
45 #define STATS_ALLOC() Stats_Alloc()
46 #define STATS_NEWCHUNK() Stats_NewChunk()
47 #define STATS_FREE() Stats_Free()
48 #define STATS_DELCHUNK() Stats_DelChunk()
51 #define STATS_NEWCHUNK()
53 #define STATS_DELCHUNK()
56 #ifdef AK_DYNA_BLK_SCRUB_MEM
57 #define SCRUB_NEW_CHUNK() memset(&memory, 0xCC, sizeof(T)*uPoolChunkSize)
58 #define SCRUB_NEW_ALLOC(pItem) memset(pItem, 0xAA, sizeof(T))
59 #define SCRUB_FREE_BLOCK(pObj) memset(pObj, 0xDD, sizeof(T))
61 #define SCRUB_NEW_CHUNK()
62 #define SCRUB_NEW_ALLOC(pItem)
63 #define SCRUB_FREE_BLOCK(pObj)
66 template <
typename T, AkUInt32 uPoolChunkSize,
class TAlloc = ArrayPoolDefault>
69 enum { kChunkMemoryBytes =
sizeof(T)*uPoolChunkSize };
74 char padding[
sizeof(T) -
sizeof(FreeBlock*) ];
80 PoolChunk() : pNextLightItem(
NULL)
83 for(
AkUInt32 i=0; i<uPoolChunkSize; ++i )
85 FreeBlock* pBlk =
reinterpret_cast<FreeBlock*
>( &memory ) + i;
86 freeList.AddFirst(pBlk);
90 inline bool BelongsTo( FreeBlock* pMem )
const {
return (
AkUInt8*)pMem >= memory && (
AkUInt8*)pMem < (memory+kChunkMemoryBytes); }
91 inline bool AllFree()
const {
return freeList.Length() == uPoolChunkSize; }
92 inline bool AllAllocd()
const {
return freeList.IsEmpty(); }
94 AkUInt8 memory[ kChunkMemoryBytes ];
95 PoolChunk* pNextLightItem;
113 template<
typename A1>
121 template<
typename A1,
typename A2>
129 template<
typename A1,
typename A2,
typename A3>
130 T*
New(A1 a1, A2 a2, A3 a3)
137 template<
typename A1,
typename A2,
typename A3,
typename A4>
138 T*
New(A1 a1, A2 a2, A3 a3, A4 a4)
153 m_chunkList.
Transfer(in_src.m_chunkList);
155 #ifdef AK_DYNA_BLK_STATS
156 uPeakUsedBytes = in_src.uPeakUsedBytes;
157 uPeakAllocdBytes = in_src.uPeakAllocdBytes;
158 uCurrentAllocdBytes = in_src.uCurrentAllocdBytes;
159 uCurrentUsedBytes = in_src.uCurrentUsedBytes;
161 in_src.uPeakUsedBytes = 0;
162 in_src.uPeakAllocdBytes = 0;
163 in_src.uCurrentAllocdBytes = 0;
164 in_src.uCurrentUsedBytes = 0;
171 FreeBlock* pItem =
NULL;
172 PoolChunk* pChunk =
NULL;
174 pChunk = m_chunkList.
First();
175 while (pChunk !=
NULL && pChunk->AllAllocd())
176 pChunk = pChunk->pNextLightItem;
180 pChunk = (PoolChunk *) TAlloc::Alloc(
sizeof( PoolChunk ) );
191 pItem = pChunk->freeList.First();
193 pChunk->freeList.RemoveFirst();
198 return reinterpret_cast<T*
>(pItem);
205 FreeBlock* pItem =
reinterpret_cast<FreeBlock*
>(pObj);
207 PoolChunk* pPrevChunk =
NULL;
208 PoolChunk* pChunk = m_chunkList.
First();
209 while (pChunk !=
NULL && !pChunk->BelongsTo(pItem))
212 pChunk = pChunk->pNextLightItem;
216 pChunk->freeList.AddFirst(pItem);
219 if (pChunk->AllFree())
222 pChunk->~PoolChunk();
228 tChunkList m_chunkList;
230 #ifdef AK_DYNA_BLK_STATS
233 uCurrentUsedBytes +=
sizeof(T);
234 uPeakUsedBytes =
AkMax(uCurrentUsedBytes, uPeakUsedBytes);
236 void Stats_NewChunk()
238 uCurrentAllocdBytes +=
sizeof(PoolChunk);
239 uPeakAllocdBytes =
AkMax(uCurrentAllocdBytes, uPeakAllocdBytes);
243 uCurrentUsedBytes -=
sizeof(T);
245 void Stats_DelChunk()
247 uCurrentAllocdBytes -=
sizeof(PoolChunk);
AkForceInline T * First()
Get first element.
#define SCRUB_FREE_BLOCK(pObj)
#define AkPlacementNew(_memory)
AKSOUNDENGINE_API void Free(AkMemPoolId in_poolId, void *in_pMemAddress)
#define SCRUB_NEW_CHUNK()
uint8_t AkUInt8
Unsigned 8-bit integer
AkForceInline bool IsEmpty() const
Empty condition.
void AddFirst(T *in_pItem)
Add element at the beginning of list.
#define AKASSERT(Condition)
void RemoveItem(T *in_pItem, T *in_pPrevItem)
Remove an element.
T * New(A1 a1, A2 a2, A3 a3, A4 a4)
T * New(A1 a1, A2 a2, A3 a3)
#define SCRUB_NEW_ALLOC(pItem)
uint32_t AkUInt32
Unsigned 32-bit integer
void Transfer(AkDynaBlkPool< T, uPoolChunkSize, TAlloc > &in_src)
void Transfer(AkListBare< T, U_NEXTITEM, COUNT_POLICY, LAST_POLICY > &in_src)
지원이 필요하신가요?
질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!
지원 페이지를 방문해 주세요
작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.
프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.
Wwise를 시작해 보세요