12GX_CORE_NAMESPACE_BEGIN()
26 GX_OPERATOR_NEW_DELETE(ALLOCATOR)
43 : _pAllocatorList(nullptr)
101 volatile Node* _pFree;
102 volatile Node* _pHead;
103 volatile Node* _pTail;
114template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
121 GX_ASSERT(_pAllocatorList !=
nullptr,
"getAllocatorList(%d) failed!!", ALLOCATOR);
124 _queueMax = queueMax + 1;
127 u32 size =
sizeof(
Node) * _queueMax;
131 GX_ERROR(
false,
"allocateMemory<number:%d, size:%d> failed!!", ALLOCATOR, size);
137 GX_MEMSET(_pBuffer, 0, size);
138 for (u32 i = 0; i < _queueMax - 1; ++i)
140 _pBuffer[i]._pNext = &_pBuffer[i + 1];
143 _pHead = _pTail = &_pBuffer[_queueMax - 1];
152template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
155 _pFree = _pHead = _pTail =
nullptr;
164template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
174 Node* pNode =
nullptr;
178 auto* pOldFree = (
Node*)_pFree;
179 auto* pOldHead = (
Node*)_pHead;
180 Node* pOldFreeNext = _pFree->_pNext;
183 if( pOldFree != _pFree )
189 if( pOldFree == pOldHead )
191 GX_TRACE(GX_TRACE_CATEGORY_CORE,
"queue is Full!!");
210 Node* pOldTail =
nullptr;
211 Node* pOldTailNext =
nullptr;
215 pOldTail = (
Node*)_pTail;
216 pOldTailNext = pOldTail->
_pNext;
219 if( _pTail != pOldTail )
251template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
270 if( _pHead != pOldHead )
276 if( pOldHead == pOldTail )
279 if( pOldHeadNext ==
nullptr )
289 temporary = pOldHeadNext->
_item;
309template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
313 return (_pHead == _pTail);
320template<
class T, GxAllocatorList::ALLOCATOR_TYPE ALLOCATOR>
323 return static_cast<u32
>(_pTail - _pHead);
326GX_CORE_NAMESPACE_END()
#define GX_ALLOCATE_MEMORY(pAllocatorList, size)
Definition GxAllocator.h:536
#define GX_SAFE_FREE_MEMORY(pAddress)
Definition GxAllocator.h:594
メモリアロケータリスト
Definition GxAllocator.h:347
static GxAllocatorList * getAllocatorList(GxAllocatorList::ALLOCATOR_TYPE number)
アロケータリスト取得 (インデックス指定)
Definition GxAllocator.cpp:284
キュー (ロック不要)
Definition GxLockFreeQueue.h:19
GxLockFreeQueue(void)
コンストラクタ
Definition GxLockFreeQueue.h:42
b32 isEmpty(void) const
キュー空判定
Definition GxLockFreeQueue.h:310
u32 getCount(void) const
データ数を取得
Definition GxLockFreeQueue.h:321
b32 enqueue(const T &src)
エンキュー
Definition GxLockFreeQueue.h:165
~GxLockFreeQueue(void)
デストラクタ
Definition GxLockFreeQueue.h:52
b32 initialize(u32 queueMax)
初期化
Definition GxLockFreeQueue.h:115
b32 dequeue(T &dst)
デキュー
Definition GxLockFreeQueue.h:252
void terminate(void)
終了
Definition GxLockFreeQueue.h:153
static b32 casPointer(volatile void **ppTarget, void *pOld, void *pNew)
ポインタCAS(Compare-And-Swap)
Definition GxThread.cpp:46
static void barrierMemory(void)
メモリバリア
Definition GxThread.cpp:64
ノード (単方向リスト)
Definition GxLockFreeQueue.h:30
T _item
実体定義
Definition GxLockFreeQueue.h:32
struct Node * _pNext
次ノード
Definition GxLockFreeQueue.h:31
32bitブーリアン
Definition GxDefine.h:173