59 indexes[pQueue->
stopIndex % depth] = index;
71 MaxHeap* heap =
new(std::nothrow) MaxHeap;
72 if (
nullptr == heap) {
75 if( !heap->create(depth) ) {
79 U8* data =
new(std::nothrow)
U8[depth*(
sizeof(msgSize) + msgSize)];
80 if (
nullptr == data) {
85 if (
nullptr == indexes) {
91 indexes[ii] = getBufferIndex(ii);
93 PriorityQueue* priorityQueue =
new(std::nothrow) PriorityQueue;
94 if (
nullptr == priorityQueue) {
100 priorityQueue->heap = heap;
101 priorityQueue->data = data;
102 priorityQueue->indexes = indexes;
103 priorityQueue->startIndex = 0;
104 priorityQueue->stopIndex = depth;
105 this->queue = priorityQueue;
109 void BufferQueue::finalize() {
110 PriorityQueue* pQueue =
static_cast<PriorityQueue*
>(this->queue);
111 if (
nullptr != pQueue)
113 MaxHeap* heap = pQueue->heap;
114 if (
nullptr != heap) {
117 U8* data = pQueue->data;
118 if (
nullptr != data) {
122 if (
nullptr != indexes)
128 this->queue =
nullptr;
134 PriorityQueue* pQueue =
static_cast<PriorityQueue*
>(this->queue);
135 MaxHeap* heap = pQueue->heap;
136 U8* data = pQueue->data;
142 bool ret = heap->push(priority, index);
146 this->enqueueBuffer(buffer, size, data, index);
154 PriorityQueue* pQueue =
static_cast<PriorityQueue*
>(this->queue);
155 MaxHeap* heap = pQueue->heap;
156 U8* data = pQueue->data;
160 bool ret = heap->pop(priority, index);
163 ret = this->dequeueBuffer(buffer, size, data, index);
167 ret = heap->push(priority, index);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
A stable max heap data structure.
void returnIndex(PriorityQueue *pQueue, NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE index)
NATIVE_UINT_TYPE checkoutIndex(PriorityQueue *pQueue, NATIVE_UINT_TYPE depth)
NATIVE_UINT_TYPE startIndex
NATIVE_UINT_TYPE * indexes
NATIVE_UINT_TYPE stopIndex