* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
*
* openGauss is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ---------------------------------------------------------------------------------------
*
* circularQueue.h
*
*
*
* IDENTIFICATION
* src/include/lib/Circularqueue.h
*
* ---------------------------------------------------------------------------------------
*/
#ifndef Circular_QUEUE_H
#define Circular_QUEUE_H
#include "postgres.h"
class CircularQueue : public BaseObject {
public:
CircularQueue(int size, MemoryContext context);
~CircularQueue();
void Init();
void Destroy();
bool LockFreeEnQueue(void* elem);
const uint32 GetStart() const;
void SetStart(uint32 index);
const uint32 GetEnd() const;
const bool IsFull();
uint32 GetLength(uint32 start, uint32 end);
void QueueTraverse();
void* GetElem(int n);
MemoryContext GetContext();
public:
uint32 head;
volatile uint32 tail;
uint32 capacity;
void** queue;
MemoryContext cxt;
};
#endif